Solved

how to access radio button

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to group array of objects ? 5 65
memory representation of int[][][] a=new int[2][][]; 10 60
main method of string class 3 109
eclipse buid path vs tomcat lib path 10 22
One of the biggest threats facing all high-value targets are APT's.  These threats include sophisticated tactics that "often starts with mapping human organization and collecting intelligence on employees, who are nowadays a weaker link than network…
Learn how the use of a bunch of disparate tools requiring a lot of manual attention led to a series of unfortunate backup events for one company.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

15 Experts available now in Live!

Get 1:1 Help Now