Jump to content
MakeWebGames

Javascript Checkboxes


War_Hero

Recommended Posts

Hi all.

I'm pretty new to Javascript and have a little problem. On my website, an admin can either select to Accept or Decline a registration from another user, but they cannot do both. Therefore, to prevent the situation of them accidentally selecting both check boxes, I need one of them to be disabled. For example, when the admin ticks the Accept box, the Decline box becomes disabled, and vice versa.

I have tried a few things using info I've found on the web, but haven't had any success. So far, this is what I have:

<html>

<head>

<script language = "javascript">

function setAccept() {

var flag = document.subchoice.accept;

flag2 = document.subchoice.decline;

flag.checked = true;

if(flag.checked == true) {

flag2.disabled = true;

}

}

function setDecline() {

var flag = document.subchoice.decline;

flag2 = document.subchoice.accept;

flag.checked = true;

if(flag.checked == true) {

flag2.disabled = true;

}

}

</script>

</head>

</html>

And the PHP form:

else {

while ($sreg = mysql_fetch_assoc($runreg)) {

print "

 

{$sreg['forename']}

{$sreg['surname']}

{$sreg['gender']}

{$sreg['form']}

{$sreg['dob']}

{$sreg['year']}

{$sreg['login_name']}

 

 

";

}

I will, in the end, need to store the accepted registrations in my database, but I will focus on that once I have solved this problem.

I've probably done the Javascript bit wrong...I'm new to this. So any help will be highly appreciated.

Thank you. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...