We help IT Professionals succeed at work.
Get Started

Having a problem with a confirm box thats in a radio button

mousemat24 asked
Last Modified: 2012-05-09
Hi there

I'm having huge problems with a confirm box in a radio button, can you please help?

If I click on a radio button where its checked I get a confirm box, this shouldnt happen, the confirm box should only appear if the radio button isnt checked.

Hope this makes sense?

I've attached the file or you can see the code below:

function ChangeAccess(territory)
  var orgValue = territory.value;
  var answer;
  var ukOptionButton = 

  var globalOptionButton = 

  if (territory.value == "globalOptionButton")
    answer = confirm("This will clear any selections in UK Grade and UK Cost 

    answer = confirm("This will clear any selections in Global Grade");

  if (answer)
    if (territory.value == "ukOptionButton")
      ukOptionButton.checked = false;
      globalOptionButton.checked = true;
    else if (territory.value == "globalOptionButton")
      ukOptionButton.checked = true;
      globalOptionButton.checked = false;

 <input id="ctl00_ContentPlaceHolder1_ukOptionButton" type="radio" 

name="ctl00$ContentPlaceHolder1$territoryGroup" value="ukOptionButton" 

onclick="ChangeAccess(this);" /><label 

for="ctl00_ContentPlaceHolder1_ukOptionButton">Restrict scope to UK territory 

only</label><br />
                <input id="ctl00_ContentPlaceHolder1_globalOptionButton" 

type="radio" name="ctl00$ContentPlaceHolder1$territoryGroup" 

value="globalOptionButton" checked="checked" onclick="ChangeAccess(this);" 

/><label for="ctl00_ContentPlaceHolder1_globalOptionButton">Increase scope to 

include all territories</label><br />

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 12 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