Hello!

I have one script that has a bunch of checkboxes in a form, all them with
different names. As you know the <form> only submit the ones that are
checked. I would like to know witch ones the user checked (they will come in
the path as variables I suppose) because I need to make a sum of the ones
that are checked, and right now I am using isset() to verify before I sum.
This is way too bad, because as I have 48 checkboxes I have too many IFs.

Please help!

Rom

Example: this is what I am doing:

script 1:

<form action=script2.php>
<input type=checkbox name=cb01 value=729>
<input type=checkbox name=cb02 value=815>
<input type=checkbox name=cb03 value=36>
<input type=checkbox name=cb04 value=988>
<input type=checkbox name=cb05 value=215>
<input type=checkbox name=cb06 value=45446>
<input type=checkbox name=cb07 value=22>
<input type=checkbox name=cb08 value=52564>
<input type=checkbox name=cb09 value=455>
<input type=checkbox name=cb10 value=21132>
</form>

script 2:
$sum = 0;
if (isset($cb01)) $sum = $sum + $cb01;
if (isset($cb02)) $sum = $sum + $cb02;
if (isset($cb03)) $sum = $sum + $cb03;
if (isset($cb04)) $sum = $sum + $cb04;
if (isset($cb05)) $sum = $sum + $cb05;
if (isset($cb06)) $sum = $sum + $cb06;
if (isset($cb07)) $sum = $sum + $cb07;
if (isset($cb08)) $sum = $sum + $cb08;
if (isset($cb09)) $sum = $sum + $cb09;
if (isset($cb10)) $sum = $sum + $cb10;

echo $sum;


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to