Solved

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

Posted on 2011-03-21
7
286 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Tag input html 4 38
Website Home page blank 4 26
How to add loader animation to a page ? 2 22
Javascript - output csv file 18 19
This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
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…

706 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

20 Experts available now in Live!

Get 1:1 Help Now