Solved

Clear Javascript Radio Buttons

Posted on 2014-01-15
4
230 Views
Last Modified: 2014-01-15
I have a form with four radio buttons. See http://lawnsprinklerservices.com/lss_form2.php at the bottom. (Services offered).

When the customer clicks one of the four choices, I will display a confirmation message & if they answer "no", I want co clear ALL the selections.

The name of the radio buttons is "plan".

I can't figure out how to do this in Javascript.

Can someone help.

Thanks
0
Comment
Question by:Richard Korts
  • 2
  • 2
4 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 39782828
replace :
jj = confirm("Please confirm selection of plan " + plan + " at a base price of $" + a);
if (!jj) {
     return false;
}

Open in new window

by :
jj = confirm("Please confirm selection of plan " + plan + " at a base price of $" + a);
if (!jj) {
     $$("[name='plan']").setProperty("checked", false);
     return false;
}

Open in new window

0
 
LVL 17

Accepted Solution

by:
OmniUnlimited earned 500 total points
ID: 39782898
I don't see any jQuery in your source (did I miss it?)

In case you don't have jQuery, you can always use the following code:

jj = confirm("Please confirm selection of plan " + plan + " at a base price of $" + a);
if (!jj) {
     var ele = document.getElementsByName("plan");
     for(var i=0;i<ele.length;i++)
        ele[i].checked = false;
     return false;
} 

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 39782921
line 3 is not jQuery but Mootools
0
 
LVL 17

Expert Comment

by:OmniUnlimited
ID: 39782980
Ah, right.  Wasn't familiar with that.  Thanks!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

831 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