I have this piece of code; what it does is that when user press a button, the item is added to the shopping cart. I use the onClick even't for this, its working perfectly on IE, however no on Firefox or related browsers. Does anyone have any idea what this may be? I looked around the net for this, and found a lot of people with the same problem, but no a definitive solution. Thanks for the help! <? if ($productrow['status']) { if ($productrow['type'] == 0 && ($isMember || $isAdmin)) { echo "<a href='#' onclick='append_cookie(\"cartcontent\", \"".$productrow['productID']."\", \"\")'>"; echo "<img src='$addtocart_button' border=0>"; echo "</a>"; echo "<a href='".FILE_DOWNLOAD."?productID=".$productrow['productID']."'>"; echo "<img src='$download_button' border=0>"; echo "</a>"; } else if ($productrow['type'] == 0 && (!$isMember && !$isAdmin)) { echo "<b>Member Download Only</b>"; } else if ($productrow['type'] == 1 || $productrow['type'] == 2) { echo "<a href='#' onclick='append_cookie(\"cartcontent\", \"".$productrow['productID']."\", \"\")'>"; echo "<img src='$addtocart_button' border=0>"; echo "</a>"; echo "<a href='#' onclick='append_cookie(\"cartcontent\", \"".$productrow['productID']."\", \"\");self.location.replace(\"".FILE_INDEX."?action=checkout\")'>"; echo "<img src='$buy_button' border=0>"; echo "</a>"; } } else { // product n/a for download or purchase echo "<img src='$na_button' border=0>"; } ?> PHP:
How do you know the problem isn't occurring in the append_cookie function? Do you have any error messages?
Yeah if it's a browser problem then it has to do with the JavaScript you're using. Just seeing the PHP or that small bit that it outputs won't help figure out what the problem is, would need to see all the client-side code.
Hmmm, ok, attached is the PHP File. Here is the Js And here is the "DEMO" site. I've been trying to solve this small problem all day, I just don't understand why y does work on IE but no in mozilla related browsers!! Thank you very much for the help.
In the demo site, you can see that if you click the purchase or add top cart buttons on IE, it does work but firefox is another story!
The read_cookie function is returning null. I'm not sure why. I think maybe you want the following line in the loop above it though. if (key == name && skips-- == 0) // Return cookie if found return value; PHP: Right now it's only evaluating the last cookie name/value pair in the array.
Hi, I think you can try form method. with form submit button name as "add to cart". then have some code in your php with the echoing javascript. i hope it will work with FF, but will slow the entire procedure. thanks.
I will try with this again today. I guess that the thing here is that IE let you get a lil lazy while coding while Firefox don't.
Also working for me, using the latest FF2. I guess you already solved it? And by the way, it should actually be in the js department.
yeah, im working on the site, now have most of the things working, still have some troublrs, but thanks to the help, here and there, im getting the way out. Im not a professional coder so any idea, subjection and help is well appreciated.