onclick interfering with form functioning?

Discussion in 'Web Design and Development' started by captainmeowtron, Jul 15, 2009.

  1. captainmeowtron macrumors member

    Joined:
    Dec 1, 2008
    #1
    I'm going to claw my brain out soon. Is the onclick and/or popup function interfering with the form functioning? Because everything does what it's supposed to (child window closes, parent window reloads to show cart) except that the cart is empty when things should be getting added.
    Here's my code (and I admit I have no idea what I'm doing):

    <html>
    <head>
    <title>jewelery</title>
    <body link="#000000" vlink="#000000" alink="#000000">
    <STYLE type="text/css">
    <!--
    A { text-decoration:none }
    -->
    </STYLE>
    <HEAD>
    </head>
    <body bgcolor="#000000" TEXT="000000">
    <table border="0" bordercolor="" style="background-color:#000000" width="100%" cellpadding="" cellspacing="">
    <tr>
    <td><img src="1.jpg"></td>
    <td>     </td>
    <td>

    <form method=\"post\" action=\"ShoppingCart.php\" onclick="window.opener.location.href='ShoppingCart.php'; window.close();" >

    Item Title: <strong><font color="E3E5CD">cool spiral pendant</font></strong><br />
    Item Serial Number: <strong>pend01</strong><br />
    <font color="E3E5CD">Icy turquoise glass wrapped in a steel spiral. 1.5 inches.</font><br />
    <br />
    Item Price: <strong><font color="E3E5CD">$30.00</font></strong><br />
    Item Shipping: <strong>$5.00</strong><br />
    Item Additional Shipping: <strong>$0.00</strong><br />
    <input name="Title" type="hidden" value="cool spiral pendant" />
    <input name="SerialNum" type="hidden" value="pend01" />
    <input name="Price" type="hidden" value="30.00" />
    <input name="Shipping1" type="hidden" value="5.00" />
    <input name="Shipping2" type="hidden" value="0.00" />
    <input name="cmd" type="hidden" id="cmd" value="1" />
    <input type="submit" name="Submit" value="Add To Cart" / >
    </form>
    </td>
    </tr>
    </table>
    <center>
    </body>
    </html>
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    Your HTML isn't valid. You have 2 body tags, which is very bad and your head tag is in the wrong spot. I think you need to look over some basic HTML tutorials so you can learn to structure a page correctly. Fixing these issues may fix your problem.

    Also be sure to use the markup options when posting code, there's a button for generic code, HTML, and PHP (it can also be used for JavaScript). This will make the code much easier for use to read.
     
  3. Darth.Titan macrumors 68030

    Darth.Titan

    Joined:
    Oct 31, 2007
    Location:
    Austin, TX
    #3
    Yeah, as angelwatt said your code is a mess. Why is there a spare body opener inside your head? You also have two opening head tags and only one head closer...
    I also couldn't figure out why you're escaping your quotes in the form opening tag?
    HTML:
    <form method=\"post\" action=\"ShoppingCart.php\" onclick="window.opener.location.href='ShoppingCart.php'; window.close();" >
     
  4. captainmeowtron thread starter macrumors member

    Joined:
    Dec 1, 2008
    #4
    I got messy with the html, but I've corrected the head and body tags and that is not the problem.
    Everything works fine, except that the items are not posting to the cart. That's what I'm really concerned with.
     
  5. captainmeowtron thread starter macrumors member

    Joined:
    Dec 1, 2008
    #5
    Awesome! Apparently that is the problem, the slashes. After staring at this stuff for a few days, it didn't seem that obvious. As I said, I have no idea what I'm doing, I simply can't afford someone to code the site so I'm cutting and pasting things left and right. I have no real concept of these languages.
     
  6. TodVader macrumors 6502a

    TodVader

    Joined:
    Sep 27, 2005
    Location:
    Quebec, Canada
    #6
    Those backslashes serve to escape characters that would change the PHP Code.

    If you string is:

    $string = "I like double quotes "! "; , the string would end before the !

    if you want to make it work you do : $string = "I like double \" quotes!";

    It looks like you took that line from a PHP echo or print statement.
     

Share This Page