Special Field with hidden button and custom page target

Hello, Just want to share with the forum, something I used today for a costumer:

So he want a field that he can put a number that is a video number, and he wants that the play button only appears if something is typed.
Then regarding what number is typed it goes for a specific page, so I end up with this:

Add a html bric and add this code:

<form onsubmit="event.preventDefault();" class="search-form">
  <label for="search" class="screen-reader-text">Search</label>
  <input id="search" type="search" class="search-input" pattern="\d*" maxlength="3" placeholder="Insert Video number with 3 digits (Ex. 001)...">
  <button onclick="window.location.href='./video' + $('#search').val() + '.html'" class="search-button">Play</button>
</form>


<style>
.search-form {
  --searchButtonWidth: 75px;
  
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
  position: relative;
}

.search-input {
  border: 0;
  margin: 0;
  padding: 0.5rem calc(var(--searchButtonWidth) + 0.5rem) 0.5rem 0.5rem;
  border-radius: 8px;
  width: 100%;
  background: #ddd;
  -webkit-appearance: none;
  font-size: 13px;
}
.search-input:focus {
  outline: 0;
  background: white;
}
.search-input:not(:placeholder-shown) ~ .search-button {
  transform: translateX(calc(-1 * var(--searchButtonWidth)));
}

.search-button {
  border: 0;
  padding: 0.5rem;
  border-radius: 8px;
  position: absolute; 
  top: 0;
  left: 100%;
  width: var(--searchButtonWidth);
  transition: 0.2s;
  background: #455A64;
  color: white;
  font-size: 13px;
  height: 100%;
}
.search-button:focus {
  outline: 0;
  background: #222;
}

.screen-reader-text {
  position: absolute;
  top: -9999px;
  left: -9999px;
}
</style>

Hope it helps someone…

NOTE: I accept suggestions for the topic tittle…

3 Likes

sounds interesting! is there a page with this working? or a small video of it working or something. Sounds good!

Hello @AdieJAM sorry but the work is for a intranet page in a company and I can’t share the final product. But just create a HTML code brick and paste the code and you can see it working…