PLEASE CHECK THE WEB PAGE FOR ME(POINT 100)!THX A LOT!

282126 2002-10-25 06:04:58
1.2 Form
Your orders page should be an interactive form that obtains the following
information (names in brackets refer to what the field must be named in the form):
Name of customer. (Name= Customername Postal address (address), suburb (suburb), state (state), postcode postcode), e-mail address (email), phone (phone) and fax (fax) of
customer.
Radio buttons for preferred contact method ?mail, phone, fax, or
e-mail (values = rmail, rphone, rfax, remail; name=
referredcontact?
Product or service code (drop-down menu based on product codes
from catalogue). (values = p1,p2,p3,p4; name = productcode?
Quantity of the product or service required. (quantity)
Preferred date of delivery in DD/MM/YYYY format (deliverydate)
Total price (price)
"Reset" and "Submit" buttons are to be used.
You need to include the following hidden fields:
<INPUT TYPE="hidden" NAME="recipient" VALUE="[insert your
e-mail address]">
<INPUT TYPE="hidden" NAME="subject" VALUE="Order form ">
<INPUT TYPE="hidden" NAME="Return URL" VALUE="[Insert
your home page]">
<INPUT TYPE="hidden" NAME="Return Link Text"
VALUE="Return to the homepage">
<INPUT TYPE="hidden" NAME="Show Results" VALUE="Yes">
<INPUT TYPE="hidden" NAME="Toggle Graphics"
VALUE="Off">
The method associated with the form is "Post."
The form is to be directed to the following CGI program:
"http://130.102.196.65/Scripts/SendMail.asp".


1.3 JavaScript (form validation)
Use JavaScript to do the following:
Validate that the quantity of the product required is a number in the
range 10-100 (orders outside this range will be processed via
traditional channels);
Display the total cost of the order based on the product code and
quantity ordered.
Ensure that an e-mail address is entered by checking that the email
field is not null.
These validation procedures should occur as soon as the relevant
information is entered (onchange). You should also ensure that the form is
not capable of submission if it still contains an error or if any field is empty.
Assume that customers are only able to order one product at a time
...全文
105 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
sun1979song 2002-10-28
  • 打赏
  • 举报
回复
<html>

<head>
<title>order</title>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function requiredFields(fieldName,fieldValue) {
if (fieldValue=="") {
alert(fieldName + " is a required field.");
return false;
}
else {
return true;
}
}

function updateTotalPrice() {
var nameTemp = document.catalogue.quantity.name;
var quantityTemp = document.catalogue.quantity.value;
if(quantityTemp == "" || isNaN(quantityTemp))
return;
var priceTemp = document.catalogue.eachprice.value;
if (requiredFields(nameTemp,quantityTemp)) {
quantityTemp = parseInt(quantityTemp);
document.catalogue.price.value = "$ " + quantityTemp * priceTemp;
}
}

function updatePrice() {
var indexNum = catalogue.productcode.selectedIndex;
switch (indexNum) {
case 1:
catalogue.eachprice.value = 54;
updateTotalPrice();
return true;
break;
case 2:
catalogue.eachprice.value = 89;
updateTotalPrice();
return true;
break;
case 3:
catalogue.eachprice.value = 28;
updateTotalPrice();
return true;
break;
case 4:
catalogue.eachprice.value = 320;
updateTotalPrice();
return true;
break;
default:
catalogue.eachprice.value = "0";
updateTotalPrice();
//alert("Please select a product title");
return false;

}
}

function checkRange(rangeName,rangeValue,lowrange,highrange) {
var quantitynum, pricenum;
if (rangeValue != "" && !isNaN(rangeValue)) {
quantitynum = parseInt(rangeValue);
if ((quantitynum < lowrange) || (quantitynum > highrange)) {
alert("The " + rangeName+ " of your order must be for a minimum of " + lowrange + " products and a maximum of " + highrange + " products; order outside this range, please process through traditional channel.");
catalogue.quantity.value = "";
catalogue.quantity.focus();
window.event.returnValue = false;
}

else {
document.catalogue.quantity.value = parseInt(rangeValue);
updateTotalPrice();
return true;
}
}else if (isNaN(rangeValue)){
alert("The quantity is not correct");
catalogue.quantity.value = "";
catalogue.quantity.focus();
window.event.returnValue = false;

}
}

function checkField() {
if(catalogue.productcode.selectedIndex == 0){
alert("Please select a product title");
return false;
}
if (catalogue.quantity.value == "" || isNaN(catalogue.quantity.value)) {
alert("Please Enter the correct quantity");
catalogue.quantity.value = "";
catalogue.quantity.focus();
return (false);
}
if (catalogue.customername.value == "") {
alert("Please Enter Your Name");
catalogue.customername.focus();
return (false);
}
if (catalogue.address.value == ""){
alert("Please Enter Your Postal Address");
catalogue.address.focus();
return (false);
}
if (catalogue.suburb.value == ""){
alert("Please Enter Suburb Name");
catalogue.suburb.focus();
return (false);
}
if (catalogue.state.value == ""){
alert("Please Enter State Name");
catalogue.state.focus();
return (false);
}
if (catalogue.postcode.value == ""){
alert("Please Enter Postcode");
catalogue.postcode.focus();
return (false);
}
if (catalogue.email.value == "") {
alert("Please Enter the Email Address");
catalogue.email.focus();
return (false);
}
var rs = /(.*)@(.*).(.*)/;
if(!rs.test(catalogue.email.value))
{
alert("Please Enter a true Email Address");
catalogue.email.focus();
return false;
}
if (catalogue.phone.value == "") {
alert("Please Enter the Phone Number");
catalogue.phone.focus();
return (false);
}
if(!checkPhoneFax("phone",catalogue.phone.value)){
catalogue.phone.focus();
return false;
}
if (catalogue.fax.value == "") {
alert("Please Enter the Fax Number");
catalogue.fax.focus();
return (false);
}
if(!checkPhoneFax("fax",catalogue.fax.value)){
catalogue.fax.focus();
return false;
}


return true;

}

function checkPhoneFax(name,value) {
if ( (value.length != 8) || (!isNaN("value")) || (value.length !=8) || (!isNaN("value"))) {
alert("The " + name + " is not a valid number. Please try again.");
return false;
}
else{
return true;
}
}

function processOrder() {
var check1 , check2 , check3;
check1 = check2 = check3 = false;
//check1 = updatePrice();
//check2 = checkRange(document.catalogue.quantity.name, document.catalogue.quantity.value,10,100);
check3 = checkField();
if (!check3) {
//alert("Your order cannot be submitted until you complete all required fields");
return false;
}
else {
alert("Your order has been processed succesfully");
return true;
}
}
//-->
</script>
</head>
sun1979song 2002-10-28
  • 打赏
  • 举报
回复

<body background="flower bg.jpg" bgproperties="fixed">
<form name="catalogue" action="http://130.102.196.65/Scripts/SendMail.asp"
ONSUBMIT="return processOrder()" method="post">
<INPUT TYPE="hidden" NAME="recipient" VALUE="s4000812@student.uq.edu.au">
<INPUT TYPE="hidden" NAME="subject" VALUE="Order Form">
<INPUT TYPE="hidden" NAME="Return URL" VALUE="http://student.uq.edu.au/~s4000812">
<INPUT TYPE="hidden" NAME="Return Link Text" VALUE="Return to the Homepage">
<INPUT TYPE="hidden" NAME="Show Results" VALUE="Yes">
<INPUT TYPE="hidden" NAME="Toggle Graphics" VALUE="Off">

<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="881" height="529">
<tr>
<td width="367" height="36">
<p align="center"><b><font color="#660000" face="Arial, Helvetica, sans-serif" size="5">             
ORDER FORM</font></b>
</td>
<td width="323" height="36">
</td>
</tr>
<tr>
<td width="368" height="493">
<table border="0" cellpadding="0" cellspacing="0" width="542" height="456">
<tr>
<td width="171" valign="top" height="27" ><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Select
Product:</font></b></td>

<td width="197">

<select name="productcode" onchange="updatePrice()">
<option value="blank">Please select a product</option>
<option value="p1">Pink Bouquet</option>
<option value="p2">Teddy Bear</option>
<option value="p3">Chocolate</option>
<option value="p4">Xbox</option>
</select>
</td>
</tr>
<tr>
<td width="171" height="27"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Enter
Quantity:</font></b></td>
<td width="367" height="27"><input type="text" name="quantity" size="3"
onchange="checkRange(this.name,this.value,10,100)"></td>
</tr>
<tr>
<td width="171" height="27"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Price:</font></b></td>
<td width="367" height="27"><input type="text" name="eachprice" size="8" readonly></td>
</tr>
<tr>
<td width="171" height="27"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Total
Price:</font></b></td>
<td width="367" height="27"><input type="text" name="price" size="8" readonly></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Delivery
Date:</font></b></td>
<td width="367" height="28"><input type="text" name="deliverydate" size="13" value="DD/MM/YYYY"></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Customer
Name:</font></b></td>
<td width="367" height="28"><input type="text" name="customername" size=40></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Postal Address:</font></b></td>
<td width="367" height="28"><input type="text" name="address" size=40></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Suburb:</font></b></td>
<td width="367" height="28"><input type="text" name="suburb" size="40"></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">State:</font></b></td>
<td width="367" height="28"><input type="text" name="state" size=10></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Postcode:</font></b></td>
<td width="367" height="28"><input type="type" name="postcode" size=10></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">E-mail:</font></b></td>
<td width="367" height="28"><input type="text" name="email" size=20 ></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Phone:</font></b></td>
<td width="367" height="28"><input type="text" name="phone" size=12 ></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Fax:</font></b></td>
<td width="367" height="28"><input type="text" name="fax" size=12 ></td>
</tr>
<tr>
<td width="540" colspan="2" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Prefer
Contact method:</font></b></td>
</tr>
<tr>
<td width="540" height="28" colspan="2">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="73">
<tr>
<td width="28%" height="27"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">E-mail
<input type=radio name="preferredcontact" value="remail" checked></font></b></td>
<td width="27%" height="27"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Phone
<input type=radio name="preferredcontact" value="rphone"></font></b></td>
<td width="23%" height="27"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Fax
<input type=radio name="preferredcontact" value="rfax"></font></b></td>
<td width="22%" height="27"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Mail
<input type=radio name=preferredcontact value="rmail"></font></b></td>
</tr>
<tr>
<td width="55%" colspan="2" height="19"></td>
<td width="45%" height="19" colspan="2"></td>
</tr>
<tr>
<td width="26%" height="27"></td>
<td width="29%" height="27"><input type="submit" name="submit" value="Submit"></td>
<td width="45%" height="27" colspan="2"><input type="reset" name="reset" value="Reset"></td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>
</td>
<td width="322" height="493">
</td>
</tr>
</table>
</center>
</div>

</form>

</body>

</html>

sun1979song 2002-10-28
  • 打赏
  • 举报
回复
<html>

<head>
<title>order</title>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function requiredFields(fieldName,fieldValue) {
if (fieldValue=="") {
alert(fieldName + " is a required field.");
return false;
}
else {
return true;
}
}

function updateTotalPrice() {
var nameTemp = document.catalogue.quantity.name;
var quantityTemp = document.catalogue.quantity.value;
if(quantityTemp == "" || isNaN(quantityTemp))
return;
var priceTemp = document.catalogue.eachprice.value;
if (requiredFields(nameTemp,quantityTemp)) {
quantityTemp = parseInt(quantityTemp);
document.catalogue.price.value = "$ " + quantityTemp * priceTemp;
}
}

function updatePrice() {
var indexNum = catalogue.productcode.selectedIndex;
switch (indexNum) {
case 1:
catalogue.eachprice.value = 54;
updateTotalPrice();
return true;
break;
case 2:
catalogue.eachprice.value = 89;
updateTotalPrice();
return true;
break;
case 3:
catalogue.eachprice.value = 28;
updateTotalPrice();
return true;
break;
case 4:
catalogue.eachprice.value = 320;
updateTotalPrice();
return true;
break;
default:
catalogue.eachprice.value = "0";
updateTotalPrice();
//alert("Please select a product title");
return false;

}
}

function checkRange(rangeName,rangeValue,lowrange,highrange) {
var quantitynum, pricenum;
if (rangeValue != "" && !isNaN(rangeValue)) {
quantitynum = parseInt(rangeValue);
if ((quantitynum < lowrange) || (quantitynum > highrange)) {
alert("The " + rangeName+ " of your order must be for a minimum of " + lowrange + " products and a maximum of " + highrange + " products; order outside this range, please process through traditional channel.");
catalogue.quantity.value = "";
catalogue.quantity.focus();
window.event.returnValue = false;
}

else {
document.catalogue.quantity.value = parseInt(rangeValue);
updateTotalPrice();
return true;
}
}
}

function checkField() {
if(catalogue.productcode.selectedIndex == 0){
alert("Please select a product title");
return false;
}
if (catalogue.customername.value == "") {
alert("Please Enter Your Name");
catalogue.customername.focus();
return (false);
}
if (catalogue.address.value == ""){
alert("Please Enter Your Postal Address");
catalogue.address.focus();
return (false);
}
if (catalogue.suburb.value == ""){
alert("Please Enter Suburb Name");
catalogue.suburb.focus();
return (false);
}
if (catalogue.state.value == ""){
alert("Please Enter State Name");
catalogue.state.focus();
return (false);
}
if (catalogue.postcode.value == ""){
alert("Please Enter Postcode");
catalogue.postcode.focus();
return (false);
}
if (catalogue.email.value == "") {
alert("Please Enter the Email Address");
catalogue.email.focus();
return (false);
}
var rs = /(.*)@(.*).(.*)/;
if(!rs.test(catalogue.email.value))
{
alert("Please Enter a true Email Address");
catalogue.email.focus();
return false;
}
if (catalogue.phone.value == "") {
alert("Please Enter the Phone Number");
catalogue.phone.focus();
return (false);
}
if(!checkPhoneFax("phone",catalogue.phone.value)){
catalogue.phone.focus();
return false;
}
if (catalogue.fax.value == "") {
alert("Please Enter the Fax Number");
catalogue.fax.focus();
return (false);
}
if(!checkPhoneFax("fax",catalogue.fax.value)){
catalogue.fax.focus();
return false;
}


return true;

}

function checkPhoneFax(name,value) {
if ( (value.length != 8) || (!isNaN("value")) || (value.length !=8) || (!isNaN("value"))) {
alert("The " + name + " is not a valid number. Please try again.");
return false;
}
else{
return true;
}
}

function processOrder() {
var check1 , check2 , check3;
check1 = check2 = check3 = false;
//check1 = updatePrice();
//check2 = checkRange(document.catalogue.quantity.name, document.catalogue.quantity.value,10,100);
check3 = checkField();
if (!check3) {
//alert("Your order cannot be submitted until you complete all required fields");
return false;
}
else {
alert("Your order has been processed succesfully");
return true;
}
}
//-->
</script>
</head>
282126 2002-10-26
  • 打赏
  • 举报
回复
CAN YOU GIVE ME A RIGHT ONE,PLEASE REVISE FOR ME!THX
sun1979song 2002-10-25
  • 打赏
  • 举报
回复
My English is poor ,i can't comprehend your comprehend.
The following is just some defect of your web page.

1.Some validation procedures occur as soon as the relevant
information is entered (onchange). If customers enter an errror data ,
though you display a message ,but the customer can still submit the form .
2.If the information is not full, you display too many messages.
3.Your function checking the e-mail is too simple , a wrong e-mail can also
pass.
4.If i input a wrong quantity or a wrong date ,the form can be submited.
282126 2002-10-25
  • 打赏
  • 举报
回复
<body background="flower bg.jpg" bgproperties="fixed">
<form name="catalogue" action="http://130.102.196.65/Scripts/SendMail.asp"
ONSUBMIT="return processOrder()" method="post">
<INPUT TYPE="hidden" NAME="recipient" VALUE="s4000812@student.uq.edu.au">
<INPUT TYPE="hidden" NAME="subject" VALUE="Order Form">
<INPUT TYPE="hidden" NAME="Return URL" VALUE="http://student.uq.edu.au/~s4000812">
<INPUT TYPE="hidden" NAME="Return Link Text" VALUE="Return to the Homepage">
<INPUT TYPE="hidden" NAME="Show Results" VALUE="Yes">
<INPUT TYPE="hidden" NAME="Toggle Graphics" VALUE="Off">

<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="881" height="529">
<tr>
<td width="367" height="36">
<p align="center"><b><font color="#660000" face="Arial, Helvetica, sans-serif" size="5">             
ORDER FORM</font></b>
</td>
<td width="323" height="36">
</td>
</tr>
<tr>
<td width="368" height="493">
<table border="0" cellpadding="0" cellspacing="0" width="542" height="456">
<tr>
<td width="171" valign="top" height="27" ><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Select
Product:</font></b></td>

<td width="197">

<select name="productcode" onchange="updatePrice()">
<option value="blank">Please select a product</option>
<option value="p1">Pink Bouquet</option>
<option value="p2">Teddy Bear</option>
<option value="p3">Chocolate</option>
<option value="p4">Xbox</option>
</select>
</td>
</tr>
<tr>
<td width="171" height="27"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Enter
Quantity:</font></b></td>
<td width="367" height="27"><input type="text" name="quantity" size="3" value="0"
onchange="checkRange(this.name,this.value,10,100)"></td>
</tr>
<tr>
<td width="171" height="27"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Price:</font></b></td>
<td width="367" height="27"><input type="text" name="eachprice" size="8"></td>
</tr>
<tr>
<td width="171" height="27"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Total
Price:</font></b></td>
<td width="367" height="27"><input type="text" name="price" size="8"></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Delivery
Date:</font></b></td>
<td width="367" height="28"><input type="text" name="deliverydate" size="13" value="DD/MM/YYYY"></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Customer
Name:</font></b></td>
<td width="367" height="28"><input type="text" name="customername" size=40></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Postal Address:</font></b></td>
<td width="367" height="28"><input type="text" name="address" size=40></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Suburb:</font></b></td>
<td width="367" height="28"><input type="text" name="suburb" size="40"></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">State:</font></b></td>
<td width="367" height="28"><input type="text" name="state" size=10></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Postcode:</font></b></td>
<td width="367" height="28"><input type="type" name="postcode" size=10></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">E-mail:</font></b></td>
<td width="367" height="28"><input type="text" name="email" size=20 onblur="requiredFields(this.name, this.value)"></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Phone:</font></b></td>
<td width="367" height="28"><input type="text" name="phone" size=12 onblur="checkPhoneFax(this.name, this.value)"></td>
</tr>
<tr>
<td width="171" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Fax:</font></b></td>
<td width="367" height="28"><input type="text" name="fax" size=12 onblur="checkPhoneFax(this.name, this.value)"></td>
</tr>
<tr>
<td width="540" colspan="2" height="28"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Prefer
Contact method:</font></b></td>
</tr>
<tr>
<td width="540" height="28" colspan="2">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="73">
<tr>
<td width="28%" height="27"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">E-mail
<input type=radio name="preferredcontact" value="remail" checked></font></b></td>
<td width="27%" height="27"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Phone
<input type=radio name="preferredcontact" value="rphone"></font></b></td>
<td width="23%" height="27"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Fax
<input type=radio name="preferredcontact" value="rfax"></font></b></td>
<td width="22%" height="27"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#660066" size="3">Mail
<input type=radio name=preferredcontact value="rmail"></font></b></td>
</tr>
<tr>
<td width="55%" colspan="2" height="19"></td>
<td width="45%" height="19" colspan="2"></td>
</tr>
<tr>
<td width="26%" height="27"></td>
<td width="29%" height="27"><input type="submit" name="submit" value="Submit"></td>
<td width="45%" height="27" colspan="2"><input type="reset" name="reset" value="Reset"></td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>
</td>
<td width="322" height="493">
</td>
</tr>
</table>
</center>
</div>

</body>

</html>
282126 2002-10-25
  • 打赏
  • 举报
回复
PLEASE CHECK FOR ME!THX(FOLLOWINS ARE CODE FROM CTRL+A)

<html>

<head>
<title>order</title>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function requiredFields(fieldName,fieldValue) {
if (fieldValue=="") {
alert(fieldName + " is a required field.");
return false;
}
else {
return true;
}
}

function updateTotalPrice() {
var nameTemp = document.catalogue.quantity.name;
var quantityTemp = document.catalogue.quantity.value;
var priceTemp = document.catalogue.eachprice.value;
if (requiredFields(nameTemp,quantityTemp)) {
quantityTemp = parseInt(quantityTemp);
document.catalogue.price.value = "$ " + quantityTemp * priceTemp;
}
}

function updatePrice() {
var indexNum = catalogue.productcode.selectedIndex;
switch (indexNum) {
case 1:
catalogue.eachprice.value = 54;
updateTotalPrice();
return true;
break;
case 2:
catalogue.eachprice.value = 89;
updateTotalPrice();
return true;
break;
case 3:
catalogue.eachprice.value = 28;
updateTotalPrice();
return true;
break;
case 4:
catalogue.eachprice.value = 320;
updateTotalPrice();
return true;
break;
default:
catalogue.eachprice.value = "0";
updateTotalPrice();
alert("Please select a product title");
return false;
}
}

function checkRange(rangeName,rangeValue,lowrange,highrange) {
var quantitynum, pricenum;
if (requiredFields(rangeName,rangeValue)) {
quantitynum = parseInt(rangeValue);
if ((quantitynum < lowrange) || (quantitynum > highrange)) {
alert("The " + rangeName+ " of your order must be for a minimum of " + lowrange + " products and a maximum of " + highrange + " products; order outside this range, please process through traditional channel.");
document.catalogue.quantity.value = "";
return false;
}
else {
updateTotalPrice();
return true;
}
}
}

function checkField() {
if (catalogue.customername.value == "") {
alert("Please Enter Your Name");
catalogue.customername.focus();
return (false);
}
else if (catalogue.address.value == ""){
alert("Please Enter Your Postal Address");
catalogue.address.focus();
return (false);
}
else if (catalogue.suburb.value == ""){
alert("Please Enter Suburb Name");
catalogue.suburb.focus();
return (false);
}else if (catalogue.state.value == ""){
alert("Please Enter State Name");
catalogue.state.focus();
return (false);
}else if (catalogue.postcode.value == ""){
alert("Please Enter Postcode");
catalogue.postcode.focus();
return (false);
}else if (catalogue.email.value == "") {
alert("Please Enter the Email Address");
catalogue.email.focus();
return (false);
}else if (catalogue.phone.value == "") {
alert("Please Enter the Phone Number");
catalogue.phone.focus();
return (false);
}else if (catalogue.fax.value == "") {
alert("Please Enter the Fax Number");
catalogue.fax.focus();
return (false);
}else {
return true;
}
}

function checkPhoneFax(name,value) {
if ( (value.length != 8) || (!isNaN("value")) || (value.length !=8) || (!isNaN("value"))) {
alert("The " + name + " is not a valid number. Please try again.");
return false;
}
else{
return true;
}
}

function processOrder() {
var check1 , check2 , check3;
check1 = check2 = check3 = false;
check1 = updatePrice();
check2 = checkRange(document.catalogue.quantity.name, document.catalogue.quantity.value,10,100);
check3 = checkField();
if ((!check1) || (!check2) || (!check3)) {
alert("Your order cannot be submitted until you complete all required fields");
return false;
}
else {
alert("Your order has been processed succesfully");
return true;
}
}
//-->
</script>
</head>

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧