Solved

how to access radio button

Posted on 2006-06-27
6
216 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Servlet Login session time and authentication using Filter 6 68
object methods vs static methods 2 93
console vs log file 16 77
spring example errors 33 254
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Fine Tune your automatic Updates for Ubuntu / Debian
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now