[thelist] js/css show div based on onchange

brian cummiskey brian at hondaswap.com
Wed Oct 20 17:04:50 CDT 2004


I'm working on a basic form for a client.  They want to show an extra 
question about the router below -if and only if- the option of DSL is 
selected/active/changed to via the select form element.

here's what i have so far:


<form name="frmdefault">
<tr>				
	<td>Current Home Internet Type</td>
	<td>
	<select name="internet_type" onchange="fillrouter();">
		<option value=""></option>
		<option value="CABLE">CABLE</option>
		<option value="DSL">DSL</option>
		<option value="DIALUP">DIALUP</option>
		<option value="ISDN">ISDN</option>
		<option value="OTHER">OTHER</option>
	</select>
	</td>
</tr>		

	
<div style="display:none;" id="dslarea">
<tr>
	<td>Router?</td>
	<td>
	<select name="router">
		<option value=""></option>
		<option value="YES">YES</option>
		<option value="NO">NO</option>
	</select>
	</td>
</tr>
</div>


</form>

Now this div shows all the time.  I don't want it to show unless the 
select above has been moved to DSL.  Appearently, disply:none; doesn't 
work like this?

here's the function I came up with, which also fails.

function fillrouter()
{
	if(document.frmdefault.internet_type.value == "DSL")
	{
		document.dslarea.style.display="inline";
	}
	else
		document.dslarea.style.display="none";
}





any suggestions?


More information about the thelist mailing list