Hi there

I have a javascript that adds up the total of values from a set of checkboxes to give the total of the amounts of all checkboxes that are checked. This is called when a checkbox is clicked. All of the checkboxes have the same name but the javascript puts them in an array.

As well as the checkboxes I have a series of other values that are given in the in the same table row. What I would like to do is create an array of F_B_IDs but only put an F_B_ID into the array if the checkbox is checked.

// function to recalculate the total amount when a checkbox is checked/unchecked
function AmountCalc(pay_amount)
{
var _defaultChecked = "";
var _values = new Array();
var IDs = new Array(); // new array to hold any F_B_IDs that have a checked checkbox
_n = 0; // array index for the IDs array
pay_amount.value = 0;

for (var _i=0;_i<document.BoBankPayIn.check.length;_i++)
{
if (document.BoBankPayIn.check[_i].checked)
{
pay_amount.value = parseFloat(pay_amount.value) + parseFloat(document.BoBankPayIn.Amounts[_i].value);
**I would like to add the relevent F_B_ID to the IDs array at this point**
}
}
}
</script>

<form METHOD="Post" ACTION="BoBankPayIn.php" name ="BoBankPayIn">
<table class="body" align="center" border="0" cellspacing="0" cellpadding="0" width="795" height="25">
<tr>
<td class="bplight" width="10" height="5">&nbsp;</td>
<td class="bplight" align="left" height="5" valign="top">
<br><b>Pay Money into the Bank {$action}</b><p>
</td>
</tr>
</table>
<table class="body" align="center" border="0" cellspacing="2" cellpadding="0" width="795" height"450">
<tr>
<td height="10" colspan="8">&nbsp;</td>
</tr>
<tr>
<td class="bplight" height="10" width="80">&nbsp;&nbsp;Account</td>
<td class="bplight" height="10">&nbsp;&nbsp;Date</td>
<td class="bplight" height="10">&nbsp;&nbsp;Method</td>
<td class="bplight" height="10">&nbsp;&nbsp;Amount</td>
<td class="bplight" height="10">&nbsp;&nbsp;Number</td>
<td class="bplight" height="10">&nbsp;&nbsp;Notes</td>
</tr>
<tr>
<td valign="top" height="20">{$account}</td>
<td valign="top" height="20">{html_select_date prefix="" field_array="Date" time=$time start_year=$startyear end_year=$endyear field_order="DMY" month_format="%02m"}</td>
<td valign="top" height="20">
<input type="button" name="cheque" onclick="window.location='BoBankPayIn.php?type=cheque'" value="Cheque"></input>
<input type ="button" name="ccard" onclick="window.location='BoBankPayIn.php?type=credit card'" value="C Card"></input>
<input type="hidden" name="action" value="post"></input>
</td>
<td valign="top" height="20"><input type="text" name="pay_amount" value="{$amount}" size="8" ></input></td>
<!--flag error if no cc or cq number given -->
<td valign="top" height="20"><input type="text" name="pay_cheque_no" size="8"></input></td>
<td valign="top" height="20"><input type="text" name="pay_notes" size="30"></input></td>
</tr>
<tr>
<td></td><td></td><td></td><td></td><td></td>
<td align="center" height="10">Paying In Slip <input type="checkbox" name="print" value="true" checked></td>
</tr>
<table align="center" width"790">
<tr>
{section name=sec1 loop=$inner}
{if $inner[sec1].F_B_ID ne $inner[sec1.index_prev].F_B_ID}
<tr>
<td> &nbsp;&nbsp;{$inner[sec1].F_AC_Code}</td>
<td> &nbsp;&nbsp;{$inner[sec1].F_B_ID}</td>
<td> &nbsp;&nbsp;{$inner[sec1].PayDate}</td>
<td> &nbsp;&nbsp;{$inner[sec1].CreditDebit}</td>
<td> &nbsp;&nbsp;{$inner[sec1].Method}</td>
<td> &nbsp;&nbsp;{$inner[sec1].Amount}</td>
<td> &nbsp;&nbsp;{$inner[sec1].Notes}</td>
<td> <input type="hidden" name"Amounts" value="{$inner[sec1].Amount}"> </td>
<td> <input type="checkbox" name="check" value="{$inner[sec1].Amount}" onclick="AmountCalc(pay_amount)" checked></td>
</tr>
{/if}
{/section}
</tr>
</table>
<tr>
<td colspan="8" valign="top" height="40">
<center>
<table align="top" border="0" cellspacing="0" cellpadding="0" width="100" height="25">
<tr>
<td valign="top"><input type="submit" value="Pay In" onclick="Alert(this.form)"></input></td>
<td width="10" valign="top">&nbsp;</td>
<td valign="top"><input type="button" value="Cancel"></input></td>
</tr>
</table>
</center>
</td>
</tr>
</table>
</form>