I would like two things to happen.
One
when a selection is made the input field updates as the total,
Two
the check boxes are dynamically generated and may sometimes be up to six and sometimes as low as one product.
This is what I have made, but I can't get it to work :(
<script type="text/javascript">
function updateTotal(){
document.getElementById('total').value =
(document.getElementById('date0').checked?
parseFloat(document.getElementById('date0').price):0) +
(document.getElementById('date1').checked?
parseFloat(document.getElementById('date1').price):0) +
(document.getElementById('date2').checked?
parseFloat(document.getElementById('date2').price):0);
}
</script>
With this as form
<form>
<td id="datecontainer" onchange="Process(this.options[this.selectedIndex].value)">
<input id="date0" type="checkbox" name="form[date]" value="blue" price="10" onChange="javascript:updateTotal();">product 1<br />
<input id="date1" type="checkbox" name="form[date]" value="green" price="30" onChange="javascript:updateTotal();">product 2<br />
<input id="date2" type="checkbox" name="form[date]" value="red" price="50" onChange="javascript:updateTotal();">product 3<br />
</td>
<td>
Total cost is:
<input name="total" id="total" type="text" readonly="readonly" style="border:0px;">
</td>
</form>
Any help will be great!