please look at my code, something is wrong and its staring at me right in the face.
please go onto http://qodeplay.com/javascript
this is what im trying to achieve and as you can see it doesnt work.
im doing this for a school assignment.
and the code:
Code:
<html><head><script type="text/javascript">
function makeChoice()
{
var val = 0;
for( i = 0; i < document.form1.fruit.length; i++ )
{
if( document.form1.fruit[i].checked == true )
{
val = document.form1.fruit[i].value;
if(val=='other')
{
document.form1.otherChoice.disabled=false;
document.form1.otherChoice.focus();
}
else
{
document.form1.otherChoice.disabled=true;
}
}
}
}
</script></head><body onload="document.form1.otherChoice.disabled=true">
<form name="form1" action="#" method="post">
<input type="radio" name="fruit" value="1" onclick="makeChoice();">Apples
<input type="radio" name="fruit" value="2" onclick="makeChoice();">Oranges
<input type="radio" name="fruit" value="3" onclick="makeChoice();">Bananas
<input type="radio" name="fruit" value="4" onclick="makeChoice();">Pears
<input type="radio" name="fruit" value="other" >Other...Please specify
<input type="text" name="otherChoice" >
</form>
</body><html>