...

View Full Version : Enable Setect



zameroth
04-16-2005, 08:01 PM
How do you enable and disable a SELECT field onClick of an input button?

KaZaK
04-16-2005, 08:06 PM
You could use something like this:


<script type="text/javascript">
<!--
function switchDisabled( elemID ) {
var elem = document.getElementById(elemID);
if( elem.disabled == true )
elem.disabled = false;
else
elem.disabled = true;
}
//--> </script>

And then use the button and select list like this:


<input type="button" onclick="switchDisabled('select-list')" value="Switch" />
<select id="select-list">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>

zameroth
04-17-2005, 08:35 PM
Thats perfect, Thank You.

:) :) :cool: :cool: :cool: :) :)

glenngv
04-18-2005, 08:43 AM
<input type="button" onclick="this.form.elements['select-list'].disabled = !this.form.elements['select-list'].disabled" value="Switch" />
<select id="select-list" name="select-list">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum