[thelist] How to Show/Hide if an option is selected in a pull-down
Peter Brunone (EasyListBox.com)
peter at easylistbox.com
Mon Aug 23 16:51:08 CDT 2004
Hi Jono,
If the value of the option is the ID of the tr, then it's really
easy...
<select name="select3"
onChange="showHide(this.options[selectedIndex].value);"
If you just want to turn on a specific element if *anything* is
selected, you can say
<select name="select3" onChange="showHide(this.selectedIndex,
'whatever');">
And then the function itself will look like this:
function showHide (selIndex, id)
{
var style = document.getElementById(id).style
if (selIndex > 0)
style.visibility = "visible";
else
style.visibility = "hidden";
}
Cheers,
Peter Brunone
___________________
www.EasyListBox.com
-----Original Message-----
From: thelist-bounces at lists.evolt.org On Behalf Of Jono
What is the best way to add this type of functionality to a pull down
list
item:
<!-- In the head -->
<script language="JavaScript" type="text/javascript">
function showHide (id)
{
var style = document.getElementById(id).style
if (style.visibility == "hidden")
style.visibility = "visible";
else
style.visibility = "hidden";
}
<!--
// -->
</script>
<!-- In the html on a Checkbox -->
<input name="add64bit" type="checkbox" id="add64bit" value="add64bit""
onClick="showHide('whatever');" />
<!-- In the html on <tr> that the checkbox shows/hides -->
<tr id="whatever" style="visibility: hidden;">Content to show/hide</tr>
I would like to use functionality similar to the above so that if the
user selects "Secondary" in the pull-down below, it will show the
content in:
<tr id="whatever" style="visibility: hidden;">Content to show/hide</tr>
<select name="select3">
<option>Choose one...</option>
<option value="dns1">Primary</option>
<option value="dns2">Secondary</option>
</select>
How can I make "<option value="dns2">Secondary</option>" once selected,
trigger the hidden <tr> to show itself?
More information about the thelist
mailing list