Solved

Jscript calculation within form

Posted on 2012-03-19
2
207 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
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…

820 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