Solved

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

Posted on 2011-03-21
7
288 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
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.

 

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

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

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

10 Experts available now in Live!

Get 1:1 Help Now