[SOLVED] Checkbox error check.
Posted: Mon Dec 01, 2003 8:22 am
I am making a form that contains two questions on witch the user can answer by checking some checkboxes.
Question 1
“Do’s”
Answer:
Checkbox 1: sit <input type="checkbox" name=”dos[]” value= “sit”>
Checkbox 2: stand<input type="checkbox" name=”dos[]” value “stand”>
Checkbox 3: run <input type="checkbox" name=”dos[]” value= “run”>
Checkbox 4: walk <input type="checkbox" name=”dos[]” value= “walk”>
Question 2
“Dont’s”
Answer:
Checkbox 1: sit <input type="checkbox" name=”donts[]” value= “sit”>
Checkbox 2: stand <input type="checkbox" name=” donts[]” value “stand”>
Checkbox 3: run <input type="checkbox" name=” donts[]” value= “run”>
Checkbox 4: walk <input type="checkbox" name=” donts[]” value= “walk”>
Now, I would like to do a check if the user did not check the same checkbox on both questions. So an error message appears when in question one and in question two “sit” is checked.
I have dese codes to output
<?
php $count=count($dos);
for ($i=0; $i<$count; $i++) {
echo $dos[$i];
}
?>
<?php
$count=count($donts);
for ($i=0; $i<$count; $i++) {
echo $donts[$i];
}
?>
I think I have to find a way to check in both arrays if there is an element that is the same.
Is there someone here who can help me with this?
Question 1
“Do’s”
Answer:
Checkbox 1: sit <input type="checkbox" name=”dos[]” value= “sit”>
Checkbox 2: stand<input type="checkbox" name=”dos[]” value “stand”>
Checkbox 3: run <input type="checkbox" name=”dos[]” value= “run”>
Checkbox 4: walk <input type="checkbox" name=”dos[]” value= “walk”>
Question 2
“Dont’s”
Answer:
Checkbox 1: sit <input type="checkbox" name=”donts[]” value= “sit”>
Checkbox 2: stand <input type="checkbox" name=” donts[]” value “stand”>
Checkbox 3: run <input type="checkbox" name=” donts[]” value= “run”>
Checkbox 4: walk <input type="checkbox" name=” donts[]” value= “walk”>
Now, I would like to do a check if the user did not check the same checkbox on both questions. So an error message appears when in question one and in question two “sit” is checked.
I have dese codes to output
<?
php $count=count($dos);
for ($i=0; $i<$count; $i++) {
echo $dos[$i];
}
?>
<?php
$count=count($donts);
for ($i=0; $i<$count; $i++) {
echo $donts[$i];
}
?>
I think I have to find a way to check in both arrays if there is an element that is the same.
Is there someone here who can help me with this?