 |
HTML Help Please Search for the answer to your question before asking it! Thanks.
|
| View previous topic :: View next topic |
| Author |
Message |
kschmidt
Joined: 26 Sep 2008
Posts: 5
|
| Posted: Fri Sep 26, 2008 10:40 am Can anyone please help with this I am a newbie. Thanks, |
|
|
Problem:
Many companies normally charge a shipping and handling charge for purchases. Create a web page that allows a user to enter a purchase price into a text box and includes a JavasScript function that calculates shipping and handling. Add functionality to the script that adds a minimum shipping and handling charge of $1.50 for any purchase that is less than or equal to $25.00. For any order over $25.00, add 10% to the total purchase price for shipping and handling. But do not include the $1.50 minimum shipping and handling charge. The formula for calculating the percentage is price * percent / 100. For example, the formula for calculating 10% of the $50.00 purchase price is 50 * 10 / 100, which results in a shipping and handling charge of $5.00. After you determine the total cost of the order (purchase plus shipping and handling), display it in an alert dialog box. |
|
|
willemvo
Joined: 27 Sep 2008
Posts: 3
|
| Posted: Sat Sep 27, 2008 3:47 am |
|
|
can you be a bit clearer i don't really know what you want...
EDIT: Maybe something like this:
Code: <html>
<head>
<script type="text/javascript">
function calculate(form) {
var purchase = document.getElementById("purch").value;
if (purchase < 25) {
document.getElementById("answer").innerHTML = purchase + 1.50;
}
else {
var result = purchase / 100 * 10 + purchase;
document.getElementById("answer").innerHTML = purchase + 1.50;
}
}
</script>
</head>
<body>
<form>
purchase: <input type="text" name="purch" id="purch">
<input type="button" onClick="calculate(this.form)">
<div id="answer">here the result will be present</div>
</form>
</body>
</html>
bye |
|
|
willemvo
Joined: 27 Sep 2008
Posts: 3
|
| Posted: Sat Sep 27, 2008 4:20 am |
|
|
willemvo wrote: can you be a bit clearer i don't really know what you want...
EDIT: Maybe something like this:
Code: <html>
<head>
<script type="text/javascript">
function calculate(form) {
var purchase = document.getElementById("purch").value;
if (purchase < 25) {
document.getElementById("answer").innerHTML = purchase + 1.50;
}
else {
var result = purchase / 100 * 10 + purchase;
document.getElementById("answer").innerHTML = purchase + 1.50;
}
}
</script>
</head>
<body>
<form>
purchase: <input type="text" name="purch" id="purch">
<input type="button" onClick="calculate(this.form)">
<div id="answer">here the result will be present</div>
</form>
</body>
</html>
bye
EDIT2:
ohh sorry i see it doesn't work yet, i'll fix that for you....
EDIT3:
It won't work; go and try yourself, this is the code i've got so far...
Code: <html>
<head>
<script type="text/javascript" lang="JavaScript1.3">
function calculate(form) {
var a = document.getElementById("purch").value;
var b = 1.50;
var c = a + b;
var d = 100;
var e = 10;
var f = a / d * e + a;
if (a <= 25) {
alert ("price: " +c)
}
else {
alert ("price: " +f)
}
}
</script>
</head>
<body>
<form>
purchase: <input type="text" name="purch" id="purch">
<input type="button" value="calculate!" onClick="calculate(this.form)">
<div id="answer">here the result will be present</div>
</form>
</body>
</html>
really srry but i've no time, maybe i'll fix it another time! |
|
|
kschmidt
Joined: 26 Sep 2008
Posts: 5
|
| Posted: Sun Sep 28, 2008 7:05 am Thanks |
|
|
| Thanks so much for your help I just have to figure out why the amount is not coming out right. |
|
|
| |
|
|
|
Powered by phpBB Search Engine Indexer
Powered by phpBB 2.0.19 © 2001, 2002 phpBB Group
|