How do i handle a boolean with a option tag
here is my html
<select name="optional_system_type" class="option_system_type">
<option selected="selected" value="0">Select the System type</option>
<option value="0">Single</option>
<option value="1">Multiple</option>
</select>
The field that i am trying to use the data for is开发者_运维知识库 a boolean and it checks to see if this is a single or multiple system...if the system is single i want to use the value 0 and 1 for multiple. The problem i see is how do i handle the "Select the System type" and is there a better way to handle this all together. It seems that i would need to change the value from 0 on the "Select the System type" option for it not to have conflicts
any suggestions
I would suggest checkbox. checkbox and radio box are not for true/false.
Don't directly assign it as bool. Leave the first value as an empty string.
Options are many. Here's one. Try replacing 0
with single
and 1
with multiple
. After all, those are the real options, not 0
and 1
.
If you really want to represent a Boolean then you should use a check box, not a select, nor radio boxes.
精彩评论