Home > Net >  <select> tag in html for creating a dropdown list of options
<select> tag in html for creating a dropdown list of options

Time:03-24

why is my select tag in my html form not working. this is my code.

<div>
<h3>Data Source</h3>
<p>Specify the Primary Data Source for the list or charts</p>
<label for="records">Records :</label>
<select name="Related Records" id="Related Records"></select>
<option value="Only Related Records">Only Related Records</option>
<option value="Some Records">Some Records</option>
<option value="Casual Records">Casual Records</option>
<option value="Specific Records">Specific Records</option>
<option value="Important Records">Important Records</option>

in the form the select button is not working

I expected the select button to work and create a dropdown list consisting of the options.

but that is not happening....

CodePudding user response:

The options of a select need to be children of that select tag:

<label for="records">Records :</label>
<select name="Related Records" id="Related Records">
    <option value="Only Related Records">Only Related Records</option>
    <option value="Some Records">Some Records</option>
    <option value="Casual Records">Casual Records</option>
    <option value="Specific Records">Specific Records</option>
    <option value="Important Records">Important Records</option>
// move closing tag to end:
</select>

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select

CodePudding user response:

you closed select tag before option-

see this-

<select name="Related Records" id="Related Records">
<option value="Only Related Records">Only Related Records</option>
<option value="Some Records">Some Records</option>
<option value="Casual Records">Casual Records</option>
<option value="Specific Records">Specific Records</option>
<option value="Important Records">Important Records</option>
</select>
  • Related