Categories
HTML

How to ensure a select form field is submitted when it is disabled with HTML?

To ensure a select form field is submitted when it is disabled with HTML, we set the name of a hidden input to the same name as the disabled select element.

For instance, we write

<select name="myselect" disabled="disabled">
  <option value="myselectedvalue" selected="selected">My Value</option>
  ....
</select>
<input type="hidden" name="myselect" value="myselectedvalue" />

to add a select and a hidden input element.

We set the name attribute of both elements to myselect.

And then the value of the hidden input will be submitted to the server.

Categories
HTML

How to clear icon inside input text with HTML?

To clear icon inside input text with HTML, we add a search input.

For instance, we write

<input type="search" />

to add an input with type attribute search to add a search input, which has the clear icon on the right of the box.

Categories
HTML

How to make an HTML text box show a hint when empty?

To make an HTML text box show a hint when empty, we set the placeholder attribute.

For instance, we write

<input name="email" placeholder="Email Address" />

to set the placeholder attribute to Email Address to show that as the placeholder when the input is empty.

Categories
HTML

How to apply the required attribute to a select field with HTML?

To apply the required attribute to a select field with HTML, we add the required attribute.

For instance, we write

<select required>
  <option value="">Please select</option>
  <option value="one">One</option>
</select>

to add the select element with the required attribute to make it a required field.

Categories
HTML

How to add full-screen iframe with a height of 100% with HTML?

To add full-screen iframe with a height of 100% with HTML, we make set the width and height to fill the screen width and height.

For instance, we write

<iframe></iframe>

to add an iframe.

Then we write

body {
  margin: 0;
}

iframe {
  display: block;
  background: #000;
  border: none;
  height: 100vh;
  width: 100vw;
}

to remove the margins from the body element.

Then we set the height and width of the iframe to fill the screen’s height and width respectively.