R
roohbir
Hello,
I need help with the following code. Would be very grateful for
comments.
I have a function called emailValid, and it is supposed to alert the
user if h/she leaves the field blank. I want to run this function
before the ComputeCost function but don't know how to go about doing
it.
Thanks in advance.
Roohbir
<html>
<head>
<script type="text/javascript" src="myOwnJavaScript.js">
</script>
</head>
<body>
<script type="text/javascript">
function emailValid()
{
email = sampleform.text2.value
if (email == "") {
alert("Invalid email address") // cannot be empty
return false
}
return true
}
function ComputeCost()
{
//create an object
obj = new ShippingInfo(sampleform.menu1.value,
sampleform.menu2.value, sampleform.text1.value, sampleform.text2.value)
//add a method
obj.GetShippingCost=GetShippingCost;
//Invoke a method.
var Cost = obj.GetShippingCost();
var message = document.getElementById("myOwndivElement");
message.innerHTML = "Cost = " + Cost;
return false;
}
</script>
<form name="sampleform" onsubmit="ComputeCost();return false;">
<p>Shipping Destination:
<select name="menu1">
<option value="">--Select a destination--</option>
<option value="Boston">Boston</option>
<option value="Seoul">Seoul</option>
</select>
<p>Shipping Type:
<select name="menu2">
<option value="">--Select a delivery method--</option>
<option value="Express Delivery">Express Delivery</option>
<option value="Standard Delivery">Standard Delivery</option>
</select>
<p>Receiver:
<input name="text1" type="text" size="20"></input>
<p>Receiver's Email Address:
<input name="text2" type="text" size="20"
onchange="emailValid();"></input>
<p><input type="submit" value="Submit">
<div id="myOwndivElement"></div>
</form>
</body>
</html>
I need help with the following code. Would be very grateful for
comments.
I have a function called emailValid, and it is supposed to alert the
user if h/she leaves the field blank. I want to run this function
before the ComputeCost function but don't know how to go about doing
it.
Thanks in advance.
Roohbir
<html>
<head>
<script type="text/javascript" src="myOwnJavaScript.js">
</script>
</head>
<body>
<script type="text/javascript">
function emailValid()
{
email = sampleform.text2.value
if (email == "") {
alert("Invalid email address") // cannot be empty
return false
}
return true
}
function ComputeCost()
{
//create an object
obj = new ShippingInfo(sampleform.menu1.value,
sampleform.menu2.value, sampleform.text1.value, sampleform.text2.value)
//add a method
obj.GetShippingCost=GetShippingCost;
//Invoke a method.
var Cost = obj.GetShippingCost();
var message = document.getElementById("myOwndivElement");
message.innerHTML = "Cost = " + Cost;
return false;
}
</script>
<form name="sampleform" onsubmit="ComputeCost();return false;">
<p>Shipping Destination:
<select name="menu1">
<option value="">--Select a destination--</option>
<option value="Boston">Boston</option>
<option value="Seoul">Seoul</option>
</select>
<p>Shipping Type:
<select name="menu2">
<option value="">--Select a delivery method--</option>
<option value="Express Delivery">Express Delivery</option>
<option value="Standard Delivery">Standard Delivery</option>
</select>
<p>Receiver:
<input name="text1" type="text" size="20"></input>
<p>Receiver's Email Address:
<input name="text2" type="text" size="20"
onchange="emailValid();"></input>
<p><input type="submit" value="Submit">
<div id="myOwndivElement"></div>
</form>
</body>
</html>