Jump to content

Can someone tell me why this doesn't work?


OBJuan

Recommended Posts

Being a nubie, I looked through the w3schools website for the coding information and tried to use it, but for some reason it isn't working. It only picks up the cost as 4.25. Can someone tell me what I'm doing wrong? :) <HTML><HEAD><TITLE>Price Adjust per Quantity</TITLE><script LANGUAGE="JavaScript"></SCRIPT></HEAD><BODY ><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" width=600><TR><TD valign=top width=150></td><td valign=top><BR> <BR><FORM name="order"><table border=0><tr><td>Quantity: </td><td><INPUT NAME="QUANTITY" TYPE=Text></td><td><INPUT TYPE=Button VALUE="Confirm Quantity" onClick="priceAdjust(this.form.QUANTITY.value)"></td></tr><tr><td>Cost:</td><td><INPUT NAME="PRICE" TYPE=Text></td></tr></table></FORM><p><br><p><br><p><center><script> function priceAdjust(text) { cost= ""; QUANTITY = "this.form.QUANTITY.value"; if (QUANTITY <= 99) { cost = 4.25; } else if (QUANTITY >= 100 && QUANTITY <= 1000) { cost = 3.99; } else if (QUANTITY >= 1001 && QUANTITY <= 5000) { cost = 3.89; } else if (QUANTITY >= 5001 && QUANTITY <= 10000) { cost = 3.79; }// else if (QUANTITY > 10000) {// cost = 3.75; } else { cost = 3.75; } document.order.PRICE.value=cost; }</SCRIPT></BODY>

Link to comment
Share on other sites

QUANTITY = "this.form.QUANTITY.value";

Strings (except the empty string) are always evaluated as 0, which is less than 99. The browser needs to see this:

QUANTITY = this.form.QUANTITY.value;

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...