De-select checkbox onclick on another checkbox

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

De-select checkbox onclick on another checkbox

Post by aceconcepts »

Hi,

I have a registration form which displays a list of dietary requirements as checkboxes.

i.e.

1. No requirements
2. Vegetarian
3. No fish etc...

I've already setup some PHP to check whether user has "checked" No requirements and any additional diets, the code then marks this as an error.

My question is how can de-select "No requirements" if any other diet is then selected? I know this will involve js I just dont know how to code it.

Thanks.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: De-select checkbox onclick on another checkbox

Post by s.dot »

aceconcepts wrote:I know this will involve js I just dont know how to code it.
:P

Moved to client-side.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

MMM JavaScript...

Code: Select all

<label for="mmm_meat" onclick="document.getElementById('mmm_carrots').checked = false;"><input checked="checked" id="mmm_meat" name="requirements" type="checkbox" />MMM Meat</label>
<br style="clear: both;" />
<label for="mmm_carrots" onclick="document.getElementById('mmm_meat').checked = false;"><input id="mmm_carrots" name="requirements" type="checkbox" />MMM Carrots</label>
Post Reply