I have a whole number of check boxes, e.g. (code from HTML Form box)
I am wanting to use server-side validation to ensure that not more than three are picked.
I have not idea how to pass (reference) the variable from the FORM HTML section to (in) the Server-side VALIDATION box.
Tried the forums but got lost...... :?
if ($Music==1) $HTML['Music']='Checked="Checked"';
if ($ESOLa==1) $HTML['ESOLa']='Checked="Checked"';
if ($Numeracya==1) $HTML['Numeracya']='Checked="Checked"';
...
....
....
<p>
<label for="Music">Music</label>
<input name="Music" type="checkbox" id="Music" value="1" <?=$HTML['Music']?> />
</p>
<p>
<label for="ESOL">ESOL</label>
<input name="ESOLa" type="checkbox" id="ESOLa" value="1" <?=$HTML['ESOLa']?> />
</p>
<p>
<label for="Numeracy">Numeracy</label>
<input name="Numeracya" type="checkbox" id="Numeracya" <?=$HTML['Numeracya']?> />
</p>
etc
I am wanting to use server-side validation to ensure that not more than three are picked.
I have not idea how to pass (reference) the variable from the FORM HTML section to (in) the Server-side VALIDATION box.
Tried the forums but got lost...... :?
Hi rcadmin,
not sure if I got you right, but you might find some useful ideas in this thread here:
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=19325&p=57945#p57945
Good success!
Cheers,
Roland
not sure if I got you right, but you might find some useful ideas in this thread here:
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=19325&p=57945#p57945
Good success!
Cheers,
Roland
Thanks, that did it :-)
There is probably a way to simplify this code, but this is what I did:
There is probably a way to simplify this code, but this is what I did:
<?
$user =& JFactory::getUser();
if ($user->gid == 0) {
return "You are not authorized to view this page!";
}
$Art=$_POST['Art'];
$Drama=$_POST['Drama'];
$Music=$_POST['Music'];
$ESOLa=$_POST['ESOLa'];
$Numeracya=$_POST['Numeracya'];
$Moari=$_POST['Moari'];
$French=$_POST['French'];
$Japanese=$_POST['Japanese'];
$ESOLb=$_POST['ESOLb'];
$Literacy=$_POST['Literacy'];
$Numeracyb=$_POST['Numeracyb'];
$Technology=$_POST['Technology'];
$FoodTechnology=$_POST['FoodTechnology'];
$Graphics=$_POST['Graphics'];
$ESOLc=$_POST['ESOLc'];
$Numeracyc=$_POST['Numeracyc'];
$Totala=$Art+$Drama+$Music+$ESOLa+$Numeracya;
$Totalb=$Moari+$French+$Japanese+$ESOLb+$Literacy+$Numeracyb;
$Totalc=$Technology+$FoodTechnology+$Graphics+$ESOLc+$Numeracyc;
$Total=$Totala+$Totalb+$Totalc;
if ($Total>3) {
return "You have selected ".($Total-3)." too many options.";
}
if ($Totala>2) {
return "You have selected too many options in line A.";
}
if ($Totalb>2) {
return "You have selected too many options in line B.";
}
if ($Totalc>2) {
return "You have selected too many options in line C.";
}
?>
This topic is locked and no more replies can be posted.