Click to See Complete Forum and Search --> : Can't get radio buttons stay checked?


Portmoon
03-03-2003, 03:50 PM
Hi,

I am constructing a calculator and want to use radio buttons to select a number of arithmetic operations. In this case 'Add', 'Subtract', 'Multiply' and 'Divide'. Although the desired symbol is displayed and it calculates the sum correctly the corresponding radio button will not remain selected i.e. checked

Can you help?

Thanks!!

-------------------------------------------------------

function InputData(checked){

document.calculator.display.value=document.calculator.display.value+checked;

}//InputData


<input type="radio" VALUE="Add" onClick="InputData('+')">+ </td>

<input type="radio" VALUE="Subtract" onClick="InputData ('-')">- </td>

<input type="radio" VALUE="Multiply" onClick="InputData('*')">* </td>

<input type="radio" VALUE="Divide" onClick="InputData('/')">/</td>

Jona
03-03-2003, 04:15 PM
"All elements must have a name"


<script>
function InputData(type){
document.calculator.display.value=document.calculator.display.value+type;
}
</script>
<form name="calculator">
<input type=text name="display">
<input type="radio" name="zippy" VALUE="Add" onClick="InputData('+')">+ </td>

<input type="radio" name="zippy" VALUE="Subtract" onClick="InputData ('-')">- </td>

<input type="radio" name="zippy" VALUE="Multiply" onClick="InputData('*')">* </td>

<input type="radio" name="zippy" VALUE="Divide" onClick="InputData('/')">/</td>

Portmoon
03-03-2003, 06:24 PM
Thanks a lot Jona, giving each element a name has worked!!

Thanks too Dave for your input, I shall make a note of those four instances in relation to the radio buttons.

Cheers to you both,

Portmoon