0

whenever i click on a radio button the value that comes out is NaN how to make it an integer

function MenuChange(){ 
newValue = parseInt(document.formcheck.Menu.value.asInt); 
document.formcheck.Price.value = newValue; 
}

<tr>
<th>Menu </th><td>270/Head <input type="radio" name="Menu" onChange="MenuChange()" value='270'></td>
<td> </td>
<td>300/Head <input type="radio" name="Menu" onChange="MenuChange()" value='300'></td><td> </td>
</tr>
2
Contributors
4
Replies
16
Views
4 Years
Discussion Span
Last Post by Shodow
0

Pass value of radio in the method

onChange="MenuChange(this.value)"

and then just assign value document.formcheck.Price.value to the passed value.

or if you want to get the value you can use like this.

alert(document.formcheck.elements['Menu'].value);

Edited by IIM

0
  • Try second option:-

instead of

document.formcheck.Menu.value.asInt

try this

document.formcheck.elements['Menu'].value

* Or there is another option:-

function MenuChange(value){ 
newValue = parseInt(value); 
document.formcheck.Price.value = newValue; 
}
<form name="formcheck">
<input type="radio" name="Menu" onChange="MenuChange(this.value)" value='270'>
</form>

Edited by IIM

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.