2009-10-06

Enable/Disable buttons according to the menu selection

<HTML>
< HEAD>

<SCRIPT LANGUAGE="JavaScript">

function Disab(val) {
frm=document.forms[0]
if(val=="enabl")
{frm.Button1.disabled=false;frm.Button2.disabled=false}
if(val=="buttn1")
{frm.Button1.disabled=true;frm.Button2.disabled=false}
if(val=="buttn2")
{frm.Button1.disabled=false;frm.Button2.disabled=true}
if(val=="disabl")
{frm.Button1.disabled=true;frm.Button2.disabled=true}
}

</SCRIPT>

</HEAD>
<BODY TEXT="000000" BGCOLOR="FFFFFF">

<form>
<div align="center">
<select name="select" onChange="Disab(this.value)">
<option value="enabl">Enable All Buttons</option>
<option value="buttn1">Disable Button 1</option>
<option value="buttn2">Disable Button 2</option>
<option value="disabl">Disable All Buttons</option>
</select>
</div>
<p align="center">
<input type=button onClick="alert('Button 1 pressed!')" value="Button 1" name="Button1">
<input type=button onClick="alert('Button 2 pressed!')" value="Button 2" name="Button2">
</form>
</BODY>
</HTML>

0 留言: