We help IT Professionals succeed at work.
Get Started

jquery check 2 radio buttons

Robert Saylor
on
379 Views
Last Modified: 2014-08-18
I have two forms that produces reqults via jquery. I have a continue button at the bottom of the page. I want to enable the continue button only when somebody selects one of the radio's from the left side of the results and a radio button from the right side of the results.

here is an example of the radio buttons generated:
Note: I am using PHP so escape characters are inserted...

Right side of a table...
<input type=\"radio\" name=\"primary_contact\" id=\"primary_contact\" value=\"$row[contactID]\">

Open in new window


Note: Each section can have multiple radio buttons. The value is changed to the value in the database.

Left side of a table...
<input type=\"radio\" name=\"secondary_contact\" id=\"secondary_contact\" value=\"$row[contactID]\">

Open in new window


Then at the bottom of the screen I have a continue button. I know how to enable/disable a button but for this test all I want to see is an alert so I know the code works.

This is what I tried using to monitor if one of the "primary_contact" radio buttons is selected and one of the "secondary_contact" radio buttons.

         if ($(".primary_contact").is(':checked') && $(".secondary_contact").is(':checked')) {
            alert('ok');
         }

Open in new window


I don't get any alerts not js errors in firebug.
Comment
Watch Question
CERTIFIED EXPERT
Expert of the Year 2014
Top Expert 2014
Commented:
This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE