Monday, 27 May 2013

Drop down selection enabling text box


<html>
<head>

<script type="text/javascript">

function Disable(aList)
{
var x=document.getElementById("text")
x.disabled=(aList.selectedIndex == 0);
}

function init()
{
document.getElementById("selectList").selectedIndex=1;
}
</script>

</head>
<body onload="init()">

<form>
<select id="selectList" onchange="Disable(this)">
<option >Off</option>
<option>On</option>
</select>
<input type="text" id="text">
</form>

</body>
</html>

No comments:

Post a Comment