Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-07-2004, 02:42 AM   PM User | #1
pyrotaz
New Coder

 
Join Date: Nov 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
pyrotaz is an unknown quantity at this point
Form Calculations/Validations

I'm fairly new to javascripting. I want to have a form on my website that will do the following.

When a person types in a shell size the script will calculate the height and size of a fireworks shell burst.

Math calculations are as followed.

Height = Shell size times 100

burst size=shell size times 75

I also want validate the form.

I'm not sure where to start. Any help would be great
pyrotaz is offline   Reply With Quote
Old 12-07-2004, 04:28 AM   PM User | #2
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
you can use this to point you in the right direction:
Code:
<html>
<head>
<script language="javascript">
function calcForm()
{
	var shellSize = document.myForm.sSize.value;

		if(isNaN(shellSize) || shellSize == "")
		{
			alert("Please enter a valid value");
			return false;
		}
		else
		{
			document.myForm.Height.value = parseFloat(shellSize) * 100;
			document.myForm.Size.value  = parseFloat(shellSize)  * 75;
			return true;
		}


}
</script>
<head>
<body>
<form name="myForm" action="">
Shell Size:<br>
<input type="text" name="sSize">
<input type="button" name="calc" value="Calculate" onclick="return calcForm();"><br>
Height:<br>
<input type="text" name="Height"  readonly="readonly"><br>
Size:<br>
<input type="text" name="Size"  readonly="readonly"><br>
</form>
</body>
</html>
__________________
-Brando
Why using tables for eating is stupid!

Last edited by Brandoe85; 12-07-2004 at 04:30 AM.. Reason: I know....i can't spell....
Brandoe85 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:07 PM.


Advertisement
Log in to turn off these ads.