Web Design & Development
[Web Design and Development Topics] [Javascript List]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Demo calculation</title>
<script type="text/javascript">
function total_it()
{
totalhere=document.form1.a.value*document.form1.b.value;
alert("The total is: "+totalhere);
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" onSubmit="total_it()" action="">
<p>
<label>Enter a number here:
<input name="a" type="text" />
</label>
</p>
<p>
<label>Enter another number here:
<input name="b" type="text" />
</label>
</p>
<input type="submit" value="Submit">
</form>
<p>The script in the body section calls a function with two parameters.</p>
<p>The function will return the product of these two parameters.</p>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Demo calculation</title>
<script type="text/javascript">
function combine_it()
{
fullname=document.form1.a.value+" "+document.form1.b.value+" "+document.form1.c.value;
alert("Your full name is "+fullname);
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" onSubmit="combine_it()" action="">
<p>
<label>First name:
<input name="a" type="text" value="First name here" />
</label>
</p>
<p>
<label>Middle name:
<input name="b" type="text" value="Middle name here" />
</label>
</p>
<p>
<label>Last name:
<input name="c" type="text" value="Last name here" />
</label>
</p>
<input type="submit" value="Submit">
</form>
<p>The script in the body section calls a function with nultiple parameters.</p>
<p>The function will return the these parameters combined.</p>
</body>
</html>