Reputation: 671
I have a drop down menu for which one option is 'Other'. Each option is tored in a table with an id ie if OptionId = 6, OptionDescription is "Other"
.
If 'Other' is chosen, a text box should appear for the user to enter specifically what the other criteria is:
<tr>
<td class="labels">
Option:
</td>
<td colspan="3">
<%=Html.DropDownList("OptionId", Utilities.OptionLookup(), "-Select One-") %>
</td>
<td>
<input id="OtherOption" type="text" />
</td>
</tr>
In this case, Utilities.OptionLookup()
gets the values from my Option table and populates the dd
. At the moment, I just have a a plain textbox OtherOption
.
I've used javascript before to do something like this but it's based on a click event. So, I set the text box to 'display:none'
, use onclick
to name my script and do the visible true or false in my script.
I want to be able to do something similar but when 'Other' is selected in my drop down.
What's the best way to do this?
Upvotes: 0
Views: 636
Reputation: 74028
You can do it the same way, but instead of the onclick
event, you utilize the onchange
event.
Upvotes: 1