Solved

how to access radio button

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
jAVA SERVLETS CODE FOR ONLINE SUPERMARKE 2 193
Need to view directory list in apache/tomcat 9 106
tomcat users xml 7 101
nested if has else if 13 88
Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
In this article, I will show you HOW TO: Suppress Configuration Issues and Warnings Alert displayed in Summary status for ESXi 6.5 after enabling SSH or ESXi Shell.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

12 Experts available now in Live!

Get 1:1 Help Now