Solved

Jscript calculation within form

Posted on 2012-03-19
2
204 Views
Last Modified: 2012-03-20
Have a form with three types of room cleaning services, each with their own price per room. When the number of rooms is chosen for one or more of the types I want it to calculate the total price.
calc-roomclean.html
0
Comment
Question by:gardena
2 Comments
 
LVL 11

Accepted Solution

by:
SANDY_SK earned 250 total points
ID: 37736966
Use This script
<SCRIPT>
var basicRoomCost = 20;
var standardRoomcost = 30;
var executiveRoomCost = 40;

function updatesum(){
	var numBasic = document.getElementsByName('basicroom')[0].value;
	var numStandard = document.getElementsByName('standardroom')[0].value;
	var numExecutive = document.getElementsByName('executiveroom')[0].value;

	var total = (numBasic*basicRoomCost)+(numStandard*standardRoomcost)+(numExecutive*executiveRoomCost);

	document.getElementsByName('totalValue')[0].value = total;
}
</SCRIPT>

Open in new window

calc-roomclean.html
0
 
LVL 1

Author Closing Comment

by:gardena
ID: 37740969
Thanks for your prompt reply, that works very well.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Wordpress type image upload 10 32
Pass through dll 2 38
Asp.net mvc 5 5 23
Automatically open all pdf links in new tab 2 15
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now