/    Sign up×
Community /Pin to ProfileBookmark

is it possible to setup a shopping cart with javascript

I was wondering if it was possible to write a program in javascript to setup a shopping cart or does it need to be a server side script.
Regards
Keith

to post a comment
JavaScript

17 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterApr 22.2005 — It's possible to do with javascript.

A few ways exist to make a shopping cart.

1. Use frames and update a hidden frame with new information using javascript as the user browses.

2. Use cookies to hold information using javascript as the user browses

3. Use form submiting techniques w/o javascript's help to pass information to the server and record it there.

4. Use help from a 3rd party like Java [b][size=1]not JavaScript[/size][/b].
Copy linkTweet thisAlerts:
@keithyauthorApr 25.2005 — i have recently just started to learn java, so it would be interesting to try and work them together but would i be better off writing the whole thing in java (when i have the experience of course ).Do you know any sites that contain any example coding of shopping carts in javascript or other? As i am struggling on this one.

cheers!

keith
Copy linkTweet thisAlerts:
@felgallApr 25.2005 — Here is a sample [URL=http://www.felgall.com/cart]frames/Javascript shopping cart[/URL] that I wrote some time ago. To see an explanation of how it works and obtain a copy of the code go [URL=http://www.felgall.com/jstip39.htm]here[/URL]
Copy linkTweet thisAlerts:
@MBComputerStoneJul 26.2006 — Look at mine best looking javascript shopping cart: http://www.mbcomputerstone.btinternet.co.uk/test/

it reads a small txt database file with the products prices etc...
Copy linkTweet thisAlerts:
@KorJul 26.2006 — you may consider an [B]AJAX[/B] solution, as well
Copy linkTweet thisAlerts:
@felgallJul 26.2006 — Look at mine best looking javascript shopping cart: http://www.mbcomputerstone.btinternet.co.uk/test/

it reads a small txt database file with the products prices etc...[/QUOTE]


It looks good but it doesn't work. Javascript has no file access so it can't write to a text file. Your cart will therefore only work on Internet Explorer and not on real web browsers.
Copy linkTweet thisAlerts:
@slaughtersJul 26.2006 — It looks good but it doesn't work. Javascript has no file access so it can't write to a text file. Your cart will therefore only work on Internet Explorer and not on real web browsers.[/QUOTE]Then all he needs to to is to simply replace the txt file with an xml file, or .js file containing the info needed.

But - JavaScript solutions to shopping carts frequently need to rely on cookies
Copy linkTweet thisAlerts:
@MBComputerStoneJul 26.2006 — IT WILL WORK ON ANY ie. i HAVE TESTED IT.
Copy linkTweet thisAlerts:
@MBComputerStoneJul 26.2006 — NEXT WEEK I'LL REPLACE IT WITH NEW PAGE DESIGN AND SMALL CHANGES IN SOURCE CODE .

SLAUGHTERS SAID THEN simply replace the txt file with an xml file, or .js file containing the info needed I KNOW WHAT YOU MEAN, THAT ACTIVEX SHOULD READ XML FILE I KNOW THAT BUT I READ TXT INSTEAD AND IT WORKS ON ANY INTERNET BROWSER AS I HAVE USED FUNCTION TO CHECK BROWSER TYPE SO I KNOW WHICH ACTIVEX TO USE.

MY TEXT BASED DATABASE IS ON MY SERVER AND I READ IT by using 2 ACITVEX.

///////////////////////////////////////////////////////////////////////////////////////////

var xml=false;



try {

xml = new ActiveXObject("Msxml2.XMLHTTP");

} catch (e) {

try {

xml = new ActiveXObject("Microsoft.XMLHTTP");

} catch (E) {

xml = false;

}

}

if (!xml && typeof XMLHttpRequest!='undefined') {

xml = new XMLHttpRequest();

}else { }//ie alert("not MOZILLA");

xml.open("GET",""+document.title+"/"+document.title+".txt", false); xml.send(null);

////////////////////////////////////////////////////////////

//LOAD IT ALL FROM xml to readtext

var readtext=xml.responseText;

// now readtext has got everything whatever you write in "txt" file must be placet in

//directory with the same name as page's title

// example if page's title is "dogfood" you expect that small txt database file to be

//found xml.open("GET",""+document.title+"/"+document.title+".txt", false); xml.send(null); it means:

xml.open("GET","digfood/dogfood.txt", false); xml.send(null);

which is located at : http://www.mbcomputerstone.btinternet.co.uk/test/dogfood/dogfood.txt and when displayed on the page it looks like this http://www.mbcomputerstone.btinternet.co.uk/test/dogfood.html

So has it helped you Keithy.

Check it for yourself Keithy at - http://www.mbcomputerstone.btinternet.co.uk/test/products_menu.html
Copy linkTweet thisAlerts:
@felgallJul 27.2006 — IT WILL WORK ON ANY ie. i HAVE TESTED IT.[/QUOTE]
It doesn't work on all browsers. I tested it and it didn't save anything that was selected.
Copy linkTweet thisAlerts:
@felgallJul 27.2006 — ActiveX only works on Internet Exploder and the file saving options there are specifically for intranet use and will not run for anyone who has proper security installed on their system. Also with IE7 Microsoft is turning off ActiveX completely as it has too many security holes to patch.
Copy linkTweet thisAlerts:
@themartyJul 27.2006 — i just tested it on Mozilla Firefox 1.5.0.5 and it seems to work

it's kind of annoying though, that with every page load i get a javascript alert saying MOZILLA
Copy linkTweet thisAlerts:
@MBComputerStoneJul 29.2006 — Keithy new shopping cart and better page design has replaced my old one.

check it out:

http://www.mbcomputerstone.btinternet.co.uk/test/

Best regards,

MBComputerStone
Copy linkTweet thisAlerts:
@MBComputerStoneJul 29.2006 — that alert saying MOZILLA and IE is only for test reasons but all remove it
Copy linkTweet thisAlerts:
@MBComputerStoneJul 29.2006 — felgall what about Mozilla, Firefox, Opera, Internet Explorer, does it work on any of them. Come on tell us . I know it does work. at least 70% of all people use Internet Explorer and 30% any other. Mozilla, Firefox, Opera & ActiveX work fine and it can not be true that it does not work on mozzila because ActiveX only works on Internet Explorer and the file saving options there are specifically for internet use and will not run for anyone who has proper security installed on their system. My internet provider request from me to enable AcitiveX or I can not use the internet. Simply ActiveX has it's use and it's used by many internet companies.

best regards,

MBComputerStone
Copy linkTweet thisAlerts:
@MBComputerStoneJul 29.2006 — I did not use custom AcitiveX but the one made by Microsoft
Copy linkTweet thisAlerts:
@MBComputerStoneJul 29.2006 — Cookies must be enabled , sorry if did not mentioned it at all. sorry fegall my appology to you from bottom of my heart. I've used cookies to save the order's data into it.
×

Success!

Help @keithy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...