Click to See Complete Forum and Search --> : Value of Radio button
vbasp
November 21st, 2003, 01:58 AM
Is it possible to get the value of a radio button on the same ASP page without submitting. I am trying to get it in java script as:
alert(document.form1.myControlName.value);
but it shows "undefined" in alert box. form1 is the name of my form. myControlName is my control which is inside the form only.
Satishpp
November 21st, 2003, 12:39 PM
<html>
<head>
<script>
function CheckVal()
{
j = document.frmtest.test.length;
for (i=0; i<j;i++)
{
if (document.frmtest.test[i].checked)
alert(document.frmtest.test[i].value);
}
}
</script>
</head>
<body>
<form name=frmtest>
<input type=radio name=test value=a>
<input type=radio name=test value=b>
<input type=radio name=test value=c>
<input type=button value=click onclick=CheckVal()>
</form>
</body>
</html>
Satish
vbasp
November 22nd, 2003, 03:29 AM
Thank you very much satish. The reply really solved my problem a lot. Hope to get such responses in future too.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.