There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
blue screen boot computer connection cpu crash css dell display driver drivers email error ethernet excel firefox firefox 3 game hard drive hardware internet internet explorer itunes laptop lcd malware monitor network networking outlook outlook 2003 outlook express partition password printer problem problems router security slow software sound trojan usb video virus vista windows windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Ca somebody please help me with a basic Javascript/HTML problem?


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
lenazav's Avatar
Computer Specs
Junior Member with 6 posts.
 
Join Date: May 2007
Location: Aberdeen, Scotland
Experience: Intermediate
13-May-2007, 07:52 PM #1
Question Ca somebody please help me with a basic Javascript/HTML problem?
Hi,

Can somebody help me. I'm quite new to Javascript and HTML and I'm having problems with the following code. What I'm trying to do is get a simple program that will work out the total charge. I just can't figure it out.

What it needs to do is work out the total charge for a customer, basically in the format shown, where the customer is charged a £3.00 delivery charge if the order value is under £25, nothing if over or equal to £25 and nothing again plus a free gift if it's equal to or over £100> I have become come completely stuck so bear with me if it looks a mess.

Can somebody please please help!!

Thanks in advance

Scott


-------------
<HTML>
<HEAD>
<TITLE>
Delivery charges
</TITLE>
<SCRIPT LANGUAGE = "JavaScript">

var orderValue; // How much the order is worth
var deliverycharge;
var total;
orderValue=window.prompt(‘How much is the order worth in Pounds Sterling?’,’’);
document.write (‘The value of your order is £’ + orderValue + ‘.
’);

orderValue = window.prompt('Please enter today\'s order value in Pounds Sterling', '');
orderValue = parseFloat(orderValue);
if (orderValue < 25)
{
document.write('Delivery Charge is £3.00')
document.write('The total charge of '+order value+' and '+deliverycharge' is '+total' + '
');
total = orderValue + 3;
}
else
{
if (orderValue >= 25)
{
document.write('Order will be delivered free')
total = orderValue
}
else
{
if (orderValue > 100)
total = orderValue
{
document.write('Order will be delivered free with a free gift')
}
else
{
document.write('
');
document.write ('Thank you for shopping with us.');
}
}
}

</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
Dave-Web1's Avatar
Member with 30 posts.
 
Join Date: Nov 2004
Location: Nottinghamshire, U.K.
Experience: Beginner
15-May-2007, 03:19 PM #2
Sorry, can't help with the javascript coding, but one idea might be to install a shopping cart that will handle this along with all the other stuff for online ordering. You can get many ready to go packages in perl or PHP that are easy to install and set up. Check out Google with 'php shopping cart' or 'cgi cart script'.

OS Commerce is free and full featured. Again sorry I cannot assist with code, good luck.
cpscdave's Avatar
Senior Member with 281 posts.
 
Join Date: Feb 2004
Experience: Intermediate
15-May-2007, 04:14 PM #3
whoa syntax errors! lol

I've fixed part of it, with it you should be able to see what the problems were and fix the rest

Code:

<HTML>
<HEAD>
<TITLE>
Delivery charges
</TITLE>

</HEAD>
<BODY>
<SCRIPT type = "text/javascript">

var orderValue; // How much the order is worth
var deliverycharge;
var total;
orderValue=window.prompt("How much is the order worth in Pounds Sterling?");
document.write ('The value of your order is £' + orderValue + '.<br>');

orderValue = window.prompt('Please enter today\'s order value in Pounds Sterling', '');
orderValue = parseFloat(orderValue);
if (orderValue < 25)
{
deliverycharge =3;
total = orderValue + deliverycharge;
document.write('Delivery Charge is £3.00')
document.write("The total charge of " + orderValue + " and " + deliverycharge + " is " + total+ '.');

}
else //only a place holder so you can see that it went completed not died
{
document.write('Delivery Charge is £3.00')
}
</SCRIPT>
</BODY>
</HTML>
lenazav's Avatar
Computer Specs
Junior Member with 6 posts.
 
Join Date: May 2007
Location: Aberdeen, Scotland
Experience: Intermediate
25-Jul-2007, 05:27 AM #4
Sorry they're delayed, but here are my thanks.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 06:01 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.