Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Clear Javascript Radio Buttons

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can I repeat this modal box over and over again...? 2 24
Dynamic Dropdowns 15 32
Html value of radio 14 28
html border input line 7 13
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…
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…
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…

856 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