Jave - onsubmit -> popup new window

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • seo_depth
    Junior Member
    • Jun 2004
    • 4

    Jave - onsubmit -> popup new window

    I have a form and would like to have it do the following:

    When the form is submited it pops up a window (e.g. 200px x 200px) which is defined by me in the script. all the variables from the form are p***ed to the PHP script in the new window.

    these are the variables I wish to send:
    $Name
    $Email
    $Telephone
    $Message


    <form action="scripts/sitemail.php" method="post" name="contact_form" target="_parent" id="contact_form">
    <table width="352" border="0" cellspacing="2" cellpadding="0">
    <tr>
    <td colspan="2"> <strong>Form:</strong></td>
    </tr>
    <tr cl***="12">
    <td colspan="2">&nbsp;</td>
    </tr>
    <tr cl***="12">
    <td width="83">Name:</td>
    <td width="255"><input name="name" type="text" id="name" size="40">
    </td>
    </tr>
    <tr cl***="12">
    <td>Email:</td>
    <td><input name="email" type="text" id="email" size="40"></td>
    </tr>
    <tr cl***="12">
    <td>Tel No:</td>
    <td><input name="number" type="text" id="number" size="40"></td>
    </tr>
    <tr cl***="12">
    <td>Message:</td>
    <td rowspan="6"><textarea name="message" cols="30" rows="6" id="message"></textarea></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>
    <div align="right"> </div></td>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="70%"><div align="left"><span ID="results" >
    </span></div></td>
    <td width="30%"><div align="right"><a href="java script:;" onClick="return validcontact()" onMouseOver="MM_swapImage('sendbutton','','images/send_in.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="images/send.jpg" name="sendbutton" width="100" height="33" border="0" id="sendbutton"></a></div></td>
    </tr>
    </table></td>
    </tr>
    </table>
    </form>

    --------------------------------------------------------------------------------



    The validation script:

    PHP:
    --------------------------------------------------------------------------------

    function validcontact()
    {
    if (document.contact_form.name.value == "")
    { document.getElementById('results').innerHTML = "<strong>* Please fill in your name.</strong>"; document.getElementById('results').style.color='#E 6322E'; return false; }
    else if (document.contact_form.email.value.search("@") == -1 || document.contact_form.email.value.search("[.*]") == -1)
    { document.getElementById('results').innerHTML = "<strong>* Please enter a valid email.</strong>"; document.getElementById('results').style.color='#E 6322E'; return false; }
    else if (document.contact_form.message.value == "")
    { document.getElementById('results').innerHTML = "<strong>* Please fill in your Message.</strong>"; document.getElementById('results').style.color='#E 6322E'; return false; }
    else
    { document.getElementById('results').innerHTML = "<strong>Sending message....</strong>"; document.getElementById('results').style.color='#E 6322E';document.contact_form.submit(); return true; }
    }

    --------------------------------------------------------------------------------


    The PHP script:

    PHP:
    --------------------------------------------------------------------------------

    $YourEmail = 'email@domainname.com';
    $date = gmdate("D dS M,Y h:i a");
    $content="
    Webmail Message

    From: $name
    Email: $email
    Tel No: $number

    Message:

    $message

    ==============================

    This email was generated on $date
    ";

    mail($YourEmail, "Webmail from $name", $content, "From: $email");
    print "Thankyou for your email"
  • kevin
    Love is life
    • Dec 2015
    • 83

    #2
    have it pop-up a page that then reads the window.opener.document.form.elements[#].values, put them into hidden form names in the pop-up window & then call your php program.

    Comment

    • Kate78
      Junior Member
      • Sep 2006
      • 2

      #3
      Thanks, I will use it

      Comment

      • gretyukecy
        Junior Member
        • Feb 2009
        • 3

        #4
        Hi

        It's easy to undestand I am reading in the way of forum the

        ___________________________
        Last edited by sonia; 03-13-2013, 11:14 AM.

        Comment

        Working...