Hello All,
I have a form where the number of input fields (lets call them B through N) is determined by the length of a php array. Above those input fields is another field (lets call this field input A) that I would like to be auto populated based on what the user enters in fields B through N.
Here is my code. The first table (with all of the “totals” fields) holds all of the input fields that I would like to auto update. These fields should auto update so that every input in EACH of the “fy” fields in the second table is added together. Example: every input in the id=”fy_{$fy.fy}
[CODE]<form method=”post” name=”submit” action=”new_item.php” accept-charset=’UTF-8′>
<table border=”box” width=”100%”>
<tr>
<td align=”center”>$<input id=”totals_high_impact_cost” size=”3″ name=”totals_high_impact_cost” maxlength=”20″ style=”text-align: right” />M</td>
<td align=”center”>$<input id=”totals_most_likely_impact_cost” size=”3″ name=”totals_most_likely_impact_cost” maxlength=”20″ style=”text-align: right” />M</td>
<td align=”center”>$<input id=”totals_low_impact_cost” size=”3″ name=”totals_low_impact_cost” maxlength=”20″ style=”text-align: right” />M</td>
<td align=”center”>$<input id=”totals_actual_expense” size=”3″ name=”totals_actual_expense” maxlength=”20″ style=”text-align: right” />M</td>
<td align=”center”>$<input id=”totals_high_mitigation_cost” size=”3″ name=”totals_high_mitigation_cost” maxlength=”20″ style=”text-align: right” />M</td>
<td align=”center”>$<input id=”totals_most_likely_mitigation_cost” size=”3″ name=”totals_most_likely_mitigation_cost” maxlength=”20″ style=”text-align: right” />M</td>
<td align=”center”>$<input id=”totals_low_mitigation_cost” size=”3″ name=”totals_low_mitigation_cost” maxlength=”20″ style=”text-align: right” />M</td>
<td align=”center”>$<input id=”totals_cost_in_scope” size=”3″ name=”totals_cost_in_scope” maxlength=”20″ style=”text-align: right” />M</td>
<td align=”center”>$<input id=”totals_unfunded_threat” size=”3″ name=”totals_unfunded_threat” maxlength=”20″ style=”text-align: right” />M</td>
</tr>
</table>
{foreach value=fy from=$php_array}
<table>
<tr>
<td align=”center”>$<input id=”fy_{$fy.fy}_high_impact_cost” size=”3″ name=”fy_{$fy.fy}_high_impact_cost” maxlength=”20″ style=”text-align: right” value=”{$fy.high_impact_cost}” onchange=”update_totals_high_impact_cost()” />M</td>
<td align=”center”>$<input id=”fy_{$fy.fy}_most_likely_impact_cost” size=”3″ name=”fy_{$fy.fy}_most_likely_impact_cost” maxlength=”20″ style=”text-align: right” value=”{$fy.most_likely_impact_cost}” />M</td>
<td align=”center”>$<input id=”fy_{$fy.fy}_low_impact_cost” size=”3″ name=”fy_{$fy.fy}_low_impact_cost” maxlength=”20″ style=”text-align: right” value=”{$fy.low_impact_cost}” />M</td>
<td align=”center”>$<input id=”fy_{$fy.fy}_actual_expense” size=”3″ name=”fy_{$fy.fy}_actual_expense” maxlength=”20″ style=”text-align: right” value=”{$fy.actual_expense}” />M</td>
<td align=”center”>$<input id=”fy_{$fy.fy}_high_mitigation_cost” size=”3″ name=”fy_{$fy.fy}_high_mitigation_cost” maxlength=”20″ style=”text-align: right” value=”{$fy.high_mitigation_cost}” />M</td>
<td align=”center”>$<input id=”fy_{$fy.fy}_most_likely_mitigation_cost” size=”3″ name=”fy_{$fy.fy}_most_likely_mitigation_cost” maxlength=”20″ style=”text-align: right” value=”{$fy.most_likely_mitigation_cost}” />M</td>
<td align=”center”>$<input id=”fy_{$fy.fy}_low_mitigation_cost” size=”3″ name=”fy_{$fy.fy}_low_mitigation_cost” maxlength=”20″ style=”text-align: right” value=”{$fy.low_mitigation_cost}” />M</td>
<td align=”center”>$<input id=”fy_{$fy.fy}_cost_in_scope” size=”3″ name=”fy_{$fy.fy}_cost_in_scope” maxlength=”20″ style=”text-align: right” value=”{$fy.cost_in_scope}” />M</td>
</tr>
</table>
{/foreach}
</form>
Please email me at [email][email protected]