0
votes

So I have a select feild with various options, the default is an option prompting the user to select from the drop down with a value of "empty". If the user declines to change the drop down before submission, rather than sending a string containing "empty" the form changes the feild to the top option within the select and sends that data instead. My code is included below:

<select class="num" name="Team_1">
    <option value="empty" class="red">Please Select</option>
    <option value="1">Manchester United</option>
    <option value="2">Bristol City</option>
    <option value="4">Spurs</option>
    <option value="9">Testing</option>
</select>

If you submit the above form with the Please select option chosen, it reverts ti Manchester United and sends a string containing "1"

Any ideas why it might be doing this and/or how i can stop it?

2

2 Answers

0
votes

You always should identify which option should be selected by default.

<option value="empty" class="red" selected="selected">Please Select</option>

Change the value of each option tag to that string you want to be send once the form is submitted.

0
votes

After further investigation I have found the option does not support the class attribute and so by adding class="red" to the option it invalidates the html which then prevents the data from being submitted and so it reverts to the next available value.