JavaScript not working online or in safari (locally)

tominated

macrumors 68000
Original poster
Jul 7, 2006
1,724
0
Queensland, Australia
I have just uploaded my proof of concept (non-working) shopping cart to check loading times, but the javascript (well, jquery javascript. i have gotten quite fond of it) doesn't work. Also, when I was viewing it in safari (locally through MAMP) the javascript didn't work either. can anybody help?

BTW: linky - http://tominatedsoftware.com/shop
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,842
7
USA
I'd guess that it can't find the local copy of the JQuery code files. Make sure the src attribute is set appropriately.
 

elppa

macrumors 68040
Nov 26, 2003
3,229
106
For whatever reason, you have to click clear once, then start adding items and it then it works.

I think this is definitely a problem with your javascript than the browser.


I'd guess that it can't find the local copy of the JQuery code files. Make sure the src attribute is set appropriately.
A quick glance at the page reveals this part is fine.
 

tominated

macrumors 68000
Original poster
Jul 7, 2006
1,724
0
Queensland, Australia
What is not working exactly.

I can add things to the cart and clear the whole cart.

I can't clear individual items though.
that is what I have implemented (i have to add the single item remove function).

i don't have a clue why you have to clear first. can a JS expert check out my script to see if it is ok?
 

elppa

macrumors 68040
Nov 26, 2003
3,229
106
that is what I have implemented (i have to add the single item remove function).

i don't have a clue why you have to clear first. can a JS expert check out my script to see if it is ok?
Disclaimer: I have only dabbled in the language and am no expert.

Change

Code:
if (applejuice == ''){
	var applejuice = '0'
	var deepsea = '0'
	var x = '0'
}
to

Code:
if (applejuice == null){
	var applejuice = '0'
	var deepsea = '0'
	var x = '0'
}
but I would do:

Code:
if (applejuice == null){
	var applejuice = '0'
}

if (deepsea == null){
	var deepsea = '0'
}

if (x == null){
	var x = '0'
}
Because otherwise aren't you assuming that if they haven't brought Apple Juice they haven't brought anything else?

If there is no apple juice cookie the the apple juice variable is set to null, and not an empty string.