options in html input

Asked

Viewed 159 times

0

in html there is a property called SELECT and also the INPUT and I would like to make a INPUT with options equal to SELECT but how can I do that? the code I used:

    <!DOCTYPE html>
    <html lang="pt-br">
      <head>
        <title>só um teste</title>
        <meta charset="utf-8">
      </head>
        <input type="text" placeholder="sua faixa etária">
          <option value="">faixa etária:</option>
          <option value="-18">menor de idade</option>
          <option value="+18">maior de idade</option>
          <option value="+60">idoso</option>
        </input>
      <body>
      </body>
    </html>
  • search: https://www.w3schools.com/tags/tag_input.asp.

  • thanks! I found an attribute called datalist with exactly what I wanted to do!

1 answer

0


Use the attribute list of the element <input type="text"> together with the element <datalist>. The element <datalist> is an element container [<option>][2] that represent the possible value options of other controls. In turn the property list indicates the list of options adopted by the control.

<!DOCTYPE html>
<html lang="pt-br">

<head>
  <title>só um teste</title>
  <meta charset="utf-8">
</head>

<body>
  <input type="text" placeholder="sua faixa etária" list="faixa">
  <datalist id="faixa">
    <option value="">faixa etária:</option>
    <option value="-18">menor de idade</option>
    <option value="+18">maior de idade</option>
    <option value="+60">idoso</option>
  </datalist>

</body>

</html>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.