Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    43
    Thanks
    7
    Thanked 0 Times in 0 Posts

    How do you post a variable to a pop-up window?

    I can't seem to figure out how to post a variable to a javascript pop-up window. I'm trying to get a the users input to post directly to the URL.

    For example:

    Code:
    <!--Pop-up-->
    <script type="text/javascript">
    <!--
    function expo() {
    window.open( "export.php?&export=<?PHP $myvar = $_POST['exportthis']; echo $myvar; ?>", "myWindow", 
    "status = 1, height = 300, width = 300, resizable = 0" )
    }
    //-->
    </script>
    
    <form action="" method="post"><input type=text value="pass-this-variable" name="exportthis">
    <input type=button value="Export" name="Exp" onClick="expo()">
    </form>
    Any suggestions?

  • #2
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Like this

    Code:
    <!--Pop-up-->
    <script type="text/javascript">
    <!--
    function expo(o) {
      var et = document.getElementById(o);
      if(et) {
        window.open( "export.php?export="+et.value, "myWindow", "status = 1, height = 300, width = 300, resizable = 0");
      }
    }
    //-->
    </script>
    
    <form action="" method="post"><input type=text value="pass-this-variable" name="exportthis" id="exportthis">
    <input type=button value="Export" name="Exp" onclick="expo('exportthins');">
    </form>
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #3
    New Coder
    Join Date
    Jul 2008
    Posts
    43
    Thanks
    7
    Thanked 0 Times in 0 Posts
    That's the right idea but it doesn't work. My button does nothing now. Possible mistype in code?

  • #4
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    My fault sorry, there was a typo.

    Change this.
    Code:
    onclick="expo('exportthins');"
    To this
    Code:
    onclick="expo('exportthis');"
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • Users who have thanked DJCMBear for this post:

    soma56 (12-24-2010)

  • #5
    New Coder
    Join Date
    Jul 2008
    Posts
    43
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by DJCMBear View Post
    My fault sorry, there was a typo.
    No need to be sorry and I appreciate your help on Christmas eve. It sure goes to show the dedication of some of us coders. That's exactly what I needed. Thank you.

    Perhaps your thinking about joining the gym in the new year as I am?
    Code:
    thins');"

  • #6
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Quote Originally Posted by soma56 View Post
    Perhaps your thinking about joining the gym in the new year as I am?
    Lol well after the christmas food I may need to
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P


  •  

    Posting Permissions

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