如何在HTML中添加下拉列表?

时间:2016-03-19 19:12:10

标签: html drop-down-menu

我目前有以下代码:

<div class="form-group">
   <label for="first_name">First Name</label>
   <input type="text" class="form-control" id="first_name" name="first_name" required placeholder="Enter Your First Name">
</div>

我希望使用“选择输入类型”添加一个包含多个选项的下拉菜单,但我不知道如何执行此操作。

任何人都可以帮助我吗?

3 个答案:

答案 0 :(得分:0)

 <div class="form-group">
   <label for="first_name">First Name</label>
   <input type="text" class="form-control" id="first_name" name="first_name" required placeholder="Enter Your First Name">
   <select id="some_select">
       <option value="value">Value</option>
       <!-- PUT THE REST OF YOUR OPTIONS HERE -->
   </select>
 </div>

答案 1 :(得分:0)

<select name="cars">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="fiat">Fiat</option>
  <option value="audi">Audi</option>
</select>

答案 2 :(得分:0)

这很简单:

&#13;
&#13;
<!-- First name label + input field -->
<div class="form-group">
   <label for="first_name">First Name</label>
   <input type="text" class="form-control" id="first_name" name="first_name" required placeholder="Enter Your First Name">
</div>

<!-- Last name label + input field -->
<div class="form-group">
   <label for="last_name">Last Name</label>
   <input type="text" class="form-control" id="last_name" name="last_name" required placeholder="Enter Your Last Name">
</div>

<!-- Gender label + select field -->
<div class="form-group">
   <label for="gender_name">Gender</label>
   <select id="gender_name">
       <option value="male">Male</option>
       <option value="female">Female</option>
   </select>
</div>
&#13;
&#13;
&#13;