--- Brian E Boothe <[EMAIL PROTECTED]> wrote:

> how can u have Values assigned to each of those selections and have them 
> Sum at a bottom Total ?
>
> <select name="division">
>  <option value="12.75" label="Math">Math</option>
>  <option value="15.25" label="Arts">Arts</option>
>  <option value="8.95" label="Science">Science</option>
> </select>
> 
> <select name="division2">
>  <option value="12.75" label="Math">Math</option>
>  <option value="15.25" label="Arts">Arts</option>
>  <option value="8.95" label="Science">Science</option>
> </select>
> 
> 
>  TOTAL

Are the values in each "option" set in PHP?  If so, add it there.  I think
someone posted a suggestion involving arrays.  Along that line, I might do
something like this with static values (they could be computed values though).

$div[1] = array("Math"=>12.75, "Arts"=>15.25, "Science"=>8.95);
$div[2] = array("Math"=>12.75, "Arts"=>15.25, "Science"=>8.95);

$fmt = " <option value='%s' label='%s'>%s</option>\n";
$tot = array();

# loop through divisions
foreach ($div as $div_num=>$div_array)
{
 # display select list
 print "<select name='division$div_num'>\n";
 # loop through the $div_array list
 foreach ($div_array as $label=>$value)
 {
  printf($fmt, $value, $label, $label);
 }
 print "</select>\n";
 $tot[$div_num] = array_sum($div_array);
}

printf("<pre>%s</pre>", print_r($tot, true));
_____

James

Reply via email to