Solved

Clear Javascript Radio Buttons

Posted on 2014-01-15
4
225 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

758 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

23 Experts available now in Live!

Get 1:1 Help Now