SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    Birmingham UK
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form Posting to a pop up window

    I have a newsletter signup form that I want to post to a pop up window with no toolbars.

    I need to post the variables rather than using the GET method (for security reasons)

    How do I do this?

    Thanks for any help.

    Si

  2. #2
    SitePoint Addict ThomasAesir's Avatar
    Join Date
    May 2002
    Location
    Sydney, Australia
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Here's a a possible solution

    Mind you you'll need to tweek it for your own needs but just to give you some ideas.

    Code:
    <script Language="JavaScript">
    function passVar(passThis){
    win2 = window.open("", "", "width=280, height=340,resizable=0,scrollbars=1,status=0,toolbar=0,top=50,left=50");
    win2.document.write("<form method=\"Post\" action=\"mailto:some@domain.xxx\" enctype=\"text\/plain\">\n");
    win2.document.write("  <input type=\"hidden\" name=\"imp1\" value=\"" + passThis + "\">\n");
    win2.document.write("<\/form>\n");
    win2.document.write("<script Language=\"JavaScript\"> document.forms[0].submit();<\/script> \n");
    win2.document.close();
    }
    </script>
    
    
    <form>
     <table border="0" cellpadding="0" cellspacing="0">
     <tr>
      <td width="80">Just a test</td>
      <td><input type="text" name="imp1" size="37"></td>
     </tr>
     <tr>
      <td>&#160</td>
      <td><input type="button" value=" Submit! " onClick="passVar(document.forms[0].imp1.value)"></td>
     </tr>
     </table>
    </form>
    As you can see I'm using javascript to pass a variable and a new form into a popup window. The new form with the variable then gets submited from the popup window

    hope that helps
    Thomas Oeser - Blueprint Software
    Web Scripting Editor v 5.2 One cool Web editing tool.
    3dcomputergraphics.com Coming Soon!

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    to improve that code use a with statement or use a variable to speed it up a bit.

    PHP Code:
    <script Language="JavaScript">
    function 
    passVar(passThis){
    win2 window.open("""""width=280, height=340,resizable=0,scrollbars=1,status=0,toolbar=0,top=50,left=50");
    with (win2.document)
    {
      
    write("<form method=\"Post\" action=\"mailto:some@domain.xxx\" enctype=\"text\/plain\">\n");
      
    write("  <input type=\"hidden\" name=\"imp1\" value=\"" passThis "\">\n");
      
    write("<\/form>\n");
      
    write("<script Language=\"JavaScript\"> document.forms[0].submit();<\/script> \n");
      
    close();
    }
    }
    </script>


    <form>
     <table border="0" cellpadding="0" cellspacing="0">
     <tr>
      <td width="80">Just a test</td>
      <td><input type="text" name="imp1" size="37"></td>
     </tr>
     <tr>
      <td> </td>
      <td><input type="button" value=" Submit! " onClick="passVar(document.forms[0].imp1.value)"></td>
     </tr>
     </table>
    </form> 
    just use something like that although there are probably better methods which, i've overlooked anyway


Bookmarks

Posting Permissions

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