SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member TomUgro's Avatar
    Join Date
    Nov 2009
    0 Post(s)
    0 Thread(s)

    Unhappy submitForm javascript not working

    Hello everyone!

    I'm hoping someone can help. This is a scipt that was written to take an html form, email it to someone and then using javascript send the information to Paypal for processing.

    I don't understand php or javascript very well and am really hoping some genius can help me. When I try to run this on my server I first get php syntax errors. Then if I get that worked out the javascript simply doesn't work. There is no redirect. The email feature is working fine though.

    Here is the code for the php containing the javascript that is not working.

    //set the email address here. 
    //$email = "test AT"; 
    $email = "youremail  AT"; 
    //set the email subject line here. 
    //$subject = "Order"; 
    $subject = "Order"; 
    // next, loop through the $_POST array, set $message = to the values of the array and a newline for formatting. 
    foreach($_POST as $key => $value) { $message .= $value."\n"; } 
    //send the email 
    mail($email, $subject, $message); $os0 = $_POST['holder']; > 
    //now, create a webpage page and dynamically submit the PayPal form with Javascript --> 
    <script language="JavaScript" type="text/javascript"> 
    function submitForm() { 
    <body onLoad="javascript&colon;submitForm()"> 
    You are being redirected to PayPal. This window will close itself in 10 seconds. 
    <form name="myForm" method="post" action="PAYPAL SITE URL (CAN'T POST IT HERE - I'M A NOOB)" target="_blank"> 
    <input type="hidden" name="business" value="pay AT"> 
    <input type="hidden" name="cmd" value="_xclick"> 
    <input type="hidden" name="item_name" value="test"> 
    <input type="hidden" name="amount" value="12.00"> 
    <input type="hidden" name="on0" value="Variables"> 
    <input type="hidden" name="os0" value="<? echo $os0 ?>">
    <!--pass along the information collected -->

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Brighton, UK
    0 Post(s)
    0 Thread(s)
    I think you should try to get the PHP working first - add a "submit" button to the form etc. (I suggest posting in the PHP forum if you're getting errors). And then, once that's working, you can move on to JS. Remember, JavaScript shouldn't be depended upon - it should be used to enhance the UX. So, if the user doesn't have JS, you still want them to be able to submit the form (with the button).

  3. #3
    SitePoint Member
    Join Date
    Jan 2009
    0 Post(s)
    0 Thread(s)
    What are the PHP syntax errors you're getting?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts