View Full Version : Please Help Me

12-26-2010, 06:46 PM
I have this code, but when I get to the last package, it returns a value of 0

I really can't understand what I am doing wrong. Please help me if you can. I aim to add another 4 categories to this calculator.

<form name=theForm onclick=getTotal() >
<div class="item">
<h1>Wedding Package:</h1>
<input name="WP" type="radio" checked value="399~~Package1"> Package 1 <br>
<input name="WP" type="radio" checked value="499~~Package2"> Package 2 <br>
<input name="WP" type="radio" checked value="599~~Package3"> Package 3 <br>
<input name="WP" type="radio" checked value="699~~Package4"> Package 4 <br>
<input name="WP" type="radio" checked value="799~~Package5"> Package 5 <br>
<input name="WP" type="radio" checked value="899~~Package6"> Package 6 <br>
<input name="WP" type="radio" checked value="999~~Package7"> Package 7 <br>
<input name="WP" type="radio" checked value="1000~~Package8"> Package 8 <br>


<span id=totalspan>

<script type=text/javascript>
function getTotal(){
var form=document.theForm;
var inputs=form.getElementsByTagName('input');
var length=inputs.length;
var total='0';

var checked=inputs[i].checked?1:0;
var value=inputs[i].value.split("~~")[0];
document.getElementById('totalspan').innerHTML="<strong>Total price will be: </strong>"+total



12-26-2010, 07:33 PM
Change this.
To this.
total = value[0];

And also change the onclick on the form tag to onsubmit and add a submit button or add the onclick to each of the radio buttons.

12-26-2010, 09:05 PM
Thank you so much

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum