1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to make this work in firefox also?

Discussion in 'PHP' started by DJuse, May 5, 2008.

  1. #1
    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:

     
    DJuse, May 5, 2008 IP
  2. LogicFlux

    LogicFlux Peon

    Messages:
    2,925
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #2
    How do you know the problem isn't occurring in the append_cookie function? Do you have any error messages?
     
    LogicFlux, May 5, 2008 IP
  3. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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.
     
    zerxer, May 5, 2008 IP
  4. DJuse

    DJuse Active Member

    Messages:
    509
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    60
    #4
    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.
     

    Attached Files:

    DJuse, May 5, 2008 IP
  5. DJuse

    DJuse Active Member

    Messages:
    509
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    60
    #5
    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!
     
    DJuse, May 5, 2008 IP
  6. LogicFlux

    LogicFlux Peon

    Messages:
    2,925
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #6
    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.
     
    LogicFlux, May 5, 2008 IP
    DJuse likes this.
  7. Sabbir

    Sabbir Banned

    Messages:
    210
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #7
    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.
     
    Sabbir, May 5, 2008 IP
    DJuse likes this.
  8. DJuse

    DJuse Active Member

    Messages:
    509
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    60
    #8
    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.
     
    DJuse, May 6, 2008 IP
  9. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #9
    The buttons work fine for me. I'm using Firefox 3.
     
    zerxer, May 7, 2008 IP
    DJuse likes this.
  10. swordbeta

    swordbeta Banned

    Messages:
    225
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    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.
     
    swordbeta, May 7, 2008 IP
    DJuse likes this.
  11. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #11
    He posted it there too I noticed.
     
    zerxer, May 7, 2008 IP
  12. DJuse

    DJuse Active Member

    Messages:
    509
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    60
    #12
    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.
     
    DJuse, May 7, 2008 IP