Page 1 of 1

De-select checkbox onclick on another checkbox

Posted: Mon Oct 01, 2007 3:35 am
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.

Re: De-select checkbox onclick on another checkbox

Posted: Mon Oct 01, 2007 3:39 am
by s.dot
aceconcepts wrote:I know this will involve js I just dont know how to code it.
:P

Moved to client-side.

Posted: Tue Oct 02, 2007 1:28 pm
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>