Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Client Side Scripting
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 10-30-2009, 02:57 PM
  #1
DJ_Markstar
Aspirant (Level 2)
 
DJ_Markstar's Avatar
 
Join Date: Oct 2009
Posts: 11
iTrader: (0)
DJ_Markstar is an unknown quantity at this point
checkboxes, calculations and forms

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>&nbsp;</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>&nbsp;</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>
DJ_Markstar is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart
 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 10:26 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.