[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

what's wrong with this script?



        I'm trying to write a form where users can click on a radio button,
click on a button labled "Compute", and have a value returned in a text box
based on which radio button was selected.  Here's what I have so far, but
it's not working for some reason.  Does anybody know what's wrong?  Thanks.

----------------------------------------------------------------------------
-------------------------------------
<html>

<head>
<script language="JavaScript">
function compute (form) 
{
   if (form.RAM.value == "4")
      form.result.value = "100"
   if (form.RAM.value == "8")
      form.result.value = "200"
   if (form.RAM.value == "16")
      form.result.value = "300"
   if (form.RAM.value == "32")
      form.result.value = "400"
   if (form.RAM.value == "64")
      form.result.value = "500"
   else
      alert ("Please input how much RAM you want.")      
}
</script>
</head>

<body>
<form>    
<input name="RAM" type="radio" value="4"> 4 megabytes <br>
<input name="RAM" type="radio" value="8"> 8 megabytes <br>
<input name="RAM" type="radio" value="16"> 16 megabytes <br>
<input name="RAM" type="radio" value="32"> 32 megabytes <br>
<input name="RAM" type="radio" value="64"> 64 megabytes <br>
<INPUT TYPE="button" VALUE="Calculate" ONCLICK="compute(this.form)">
<INPUT TYPE="text" NAME="result" SIZE=15 >
</form>
</body>

</html>

--------------------------------------------------------------------
For help about the list, please send a message to 'majordomo@obscure.org'
with the message body 'help'. To unsubscribe, send a message to
'majordomo@obscure.org' with the message body 'unsubscribe javascript'.
List archives and pointer to FAQ: http://www.obscure.org/javascript/