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>

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);

how i don't get it

  • 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>

it works tnx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.