Solved

Radio Buttons work in IE but don't work in FireFox

Posted on 2011-03-21
7
290 Views
Last Modified: 2012-05-11
the following works in IE but not in Firefox. Please help:

function test()
      {
          var rM = document.getElementsByName('rMonthly');
        rM[0].checked = true;
      }

<a href="javascript:test();">test</a>
    <input id="rMonthly" runat="server" type="radio" name="rSubscription" value="Monthly" /><b>Monthly</b>
   
0
Comment
Question by:wilcor14
  • 4
  • 3
7 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 35184988
Corrected :

note : the name is rSubscription not rMonthly
function test() {
   var rM = document.getElementById('rMonthly');
   rM.checked = true;
}

<a href="javascript:test();">test</a>
<input id="rMonthly" type="radio" name="rSubscription" value="Monthly" /><b>Monthly</b>

Open in new window

0
 

Author Comment

by:wilcor14
ID: 35190716
Thanks leakim971

But what if I have multiple radio buttons such as:
<input id="rMonthly" type="radio" name="rSubscription" value="Monthly" /><b>Monthly</b>
<input id="rBiAnnual" type="radio" name="rSubscription" value="BiAnnual" /><b>BiAnnual</b>
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35190859
what do you want to do ?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:wilcor14
ID: 35190971
I want to select the rMonthly radio button. Your suggestion mentions that it should be the name is rSubscription not rMonthly. Well, there are now 2 rSubscription names so that won't work right?
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 35190993
no, I use the ID instead the name. ID must be unique in a page. It's your case so no problem.

input id="rMonthly" t
input id="rBiAnnual"

function test() {
   var rM = document.getElementById('rMonthly');
   rM.checked = true;
}
0
 

Author Comment

by:wilcor14
ID: 35191412
Yes, this in my dilemma. It works fine in IE but not in FireFox.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35194716
the code is fine, the error is somewhere else
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add a Location and Color Price based on select box selected option 17 66
email validation 9 48
converting document.write() to innerHTML 7 48
REST call Failing 1 11
Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

749 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