Solved

how to access radio button

Posted on 2006-06-27
6
219 Views
Last Modified: 2010-04-01
I see the following error onclicking the radio button.
Error: 'document.form.revrp' is null or not an object

Here is the code

<BODY>
<SCRIPT>
function getSelRadio(var radiogrp)
{
      for (var counter = 0; counter < radiogrp.length; counter++)
      {
             alert(radiogrp[counter].value);
       }
}
      </script>
      
<TABLE BGCOLOR="white" BORDER="0">
      <TR>
          <TD><input type="radio" name="revgrp" value="0"  checked>Default<br></TD>
          <TD><input type="radio" name="revgrp" value="2" onClick = "getSelRadio(document.form.revgrp)" >Maximum value of x Axis<br></TD>
            <TD> <input name="maxrevaxis" type="text" value="20000" /> </TD>
      </TR>

</TABLE>
</BODY>
0
Comment
Question by:MFC123
  • 2
6 Comments
 
LVL 16

Accepted Solution

by:
suprapto45 earned 100 total points
ID: 16997725
Hi,

Try to change it as

onClick = "getSelRadio(this)"

David
0
 

Assisted Solution

by:gotekareddy
gotekareddy earned 100 total points
ID: 17029832
better go for this :

<html>
<head>
<script language="javascript">
function getSelRadio(var radiogrp)
{
     for (var counter = 0; counter < radiogrp.length; counter++)
     {
        if(radiogrp[counter].checked)
          {
                alert(radiogrp[counter].value);
          }
      }
}


</script>
</head>
<body>
<form>
<TABLE BGCOLOR="white" BORDER="0">
     <TR>
         <TD><input type="radio" name="revgrp" value="0"  checked>Default<br></TD>
         <TD><input type="radio" name="revgrp" value="2" onClick = "getSelRadio(this)" >Maximum value of x Axis<br></TD>
          <TD> <input name="maxrevaxis" type="text" value="20000" /> </TD>
     </TR>

</TABLE>

</form
</body>
</html>
0
 
LVL 9

Assisted Solution

by:owenli27
owenli27 earned 100 total points
ID: 17101497
I have same problem before. I solved it by using this:

function getSelRadio()
{
     for (var counter=0; counter < document.MyForm.radiogrp.length; counter++)
     {
           alert( document.MyForm.radiogrp[counter].value );
     }
}

<FORM NAME="MyForm" METHOD="POST" ACTION="./doWhatEver.do">  
<TABLE BGCOLOR="white" BORDER="0">
     <TR>
         <TD><input type="radio" name="revgrp" value="0"  checked>Default<br></TD>
         <TD><input type="radio" name="revgrp" value="2" onClick="getSelRadio()">Maximum value of x Axis<br></TD>
          <TD> <input name="maxrevaxis" type="text" value="20000" /> </TD>
     </TR>
</TABLE>
</FORM>
</BODY>
0
 
LVL 9

Expert Comment

by:owenli27
ID: 17105412
document.MyForm.radiogrp  should be  document.MyForm.revgrp

function getSelRadio()
{
     for (var counter=0; counter < document.MyForm.revgrp.length; counter++)
     {
           alert( document.MyForm.revgrp[counter].value );
     }
}
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Giving access to ESXi shell console is always an issue for IT departments to other Teams, or Projects. We need to find a way so that teams can use ESXTOP for their POCs, or tests without giving them the access to ESXi host shell console with a root …
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question