We help IT Professionals succeed at work.
Get Started

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

mousemat24
mousemat24 asked
on
617 Views
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:

thanks
<html>
<head>
<script>
function ChangeAccess(territory)
{
  var orgValue = territory.value;
  var answer;
  var ukOptionButton = 

document.getElementById("ctl00_ContentPlaceHolder1_ukOptionButton");
  var globalOptionButton = 

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

Centre");
  }
  else
  {
    answer = confirm("This will clear any selections in Global Grade");
  }
  

  if (answer)
  {
    document.forms[0].submit();
  }
  else
  {
    if (territory.value == "ukOptionButton")
    {
      ukOptionButton.checked = false;
      globalOptionButton.checked = true;
    } 
    else if (territory.value == "globalOptionButton")
    {
      ukOptionButton.checked = true;
      globalOptionButton.checked = false;
    }
  }
}
</script>
</head>
<body>
<form>

 <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 />
</form>
</body>
</html>

Open in new window

tt.htm
Comment
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