I would like to create a 2 text boxes. The first text box will be the edit text box where I can enter in numbers. The second text box will display the dollar amount. Below are the qty and unit prices:
QTY --------- Unit Price
1-5------------$250
6-10-----------$225
11-15----------$200
16 and up-----$180
Let say I wanted to enter quantity of 8, it should calculate in the amount of $225.00 because it fall into that qty. If I enter quantity of 100, the price should show up in the second display box of $180.00. Can the price change immediately when entering the QTY or does the user have to refresh the browser? That would not be a very good tool than. It should chance the pricing right away when a user enter the quantity. Please create this so there are no decimal .00, I just need the dollar amount $245
One other thing, I would like for the edit text box to give an error or alert message "Please enter a valid number." when someone entering letters or strange characters. The text box should except numbers ONLY.
Here is what I have started:
- Code: Select all
<html>
<body>
<script language="javascript">
function is_valid(text)
{
var isValid = true;
var validChars = "1234567890";
var CharIndex;
{
if (valiChars.indexOf (text.CharAt (CharIndex).toLowerCase()) <0)
{
isValid = false;
alert("Please enter a valid number.");
break
}
}
return isValid;
}
</script>
QTY <input type="text" name="textboxwidth" size="3" maxlength="1000">
Unit Price $ <input type="text" name="textboxwidth" size="8" maxlength="1000">
</body>
</html>
Thanks in advance!![/code]


