Hi there guys, below is some code for a calculator that adds up three separate lists, and then produces the result in a textbox.
What I need to know is how to add in a checkbox to this. What I have found is that the 'value' of the checkbox is added whether it is ticked or not. What I'd like is for the value of that checkbox to only be added to the total when the box is ticked by the client.
Thanks!
Quote:
<form id="form1" name="form1" method="post" action="">
<p>
<label>How many hours would you like the disco for?
<select name="Hours" id="Hours">
<option selected="selected">Please Select...</option>
<option value="225">4</option>
<option value="250">5</option>
<option value="300">6</option>
<option value="350">7</option>
</select>
</label>
</p>
<p>
<label> Please select which county you live in.
<select name="Location" id="Location">
<option>Please Select...</option>
<option value="0">Essex</option>
<option value="25">Kent</option>
<option value="50">London</option>
<option value="25">Surrey</option>
</select>
</label>
</p>
<p>
<label>How would you like to customize your disco?
<select name="Extras" id="Extras">
<option selected="selected">Please Select...</option>
<option value="-50">Sunday to thursday</option>
<option value="-25">Friday</option>
<option value="0">Saturday</option>
</select>
</label>
</p>
<p>
<label>
<input type="button" name="CalculateButton" id="CalculateButton" value="Calculate!" onClick="calcField_form1();"/>
</label>
<label>
<input name="displayAnswer" type="text" id="displayAnswer" readonly="readonly" />
</label>
</p>
<p> </p>
<p>*These prices are for adult functions, please click here for a quote for your childrens party or click here for a quote for your wedding</p>
<p>**Extras are available, to see a list of these, please click here</p>
<p> </p>
</form>
<script>
function calcField_form1(){
result = parseInt(document.form1.Hours.value) + parseInt(document.form1.Location.value) + parseInt(document.form1.Extras.value);
document.getElementById('displayAnswer').value = result;
}
</script></p>
|