Submit button open in new window code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dster77
    New Member
    • Jan 2014
    • 1

    #1

    Submit button open in new window code?

    I am writing a few lines of code for a form that takes the input from the user and uses it to go to a subdomain of my URL (because each user has their own subdomain). I need to iframe this into another page, so I need the result to open in a new window. For some reason I am having a lot of trouble with this. Here is my code:

    Code:
    	<form 
    	onsubmit="window.location='http://'+this.subdomain.value+'.myurl.com/';
     return false" target="_blank">
    	<input type="text" name="subdomain"/>
    	<input type="submit" value="Continue">
    	</form>
    I replace my actual URL with 'myurl' for the purpose of this post.


    Any suggestions?
    Thanks
    Last edited by Rabbit; Jan 26 '14, 02:39 AM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • Claus Mygind
    Contributor
    • Mar 2008
    • 571

    #2
    Use window.open() instead of window.location . Open always opens a new window and can take parameters.

    read more about it here

    Comment

    • sudhakar1
      New Member
      • Jan 2014
      • 15

      #3
      Hi,
      if you open the new window mean try do this
      Code:
      window.open("Your url","_blank","toolbar=yes, scrollbars=yes, resizable=yes,");
      Last edited by zmbd; Jan 29 '14, 06:04 AM. Reason: [Z{Please use the [CODE/] button to format posted code script and formated text - Please read the FAQ}]

      Comment

      • hemal8888
        New Member
        • Mar 2013
        • 9

        #4
        Hii In Below i have put completed code in php it is completely testing by me
        File 1 : wino.php
        Code:
        <?php 
           if(isset($_POST['submit']))
           {
           	$val = $_POST['subdomain'];
         ?>
         <script>
        window.open("http://localhost/win2.php?val=<?php echo $val; ?>","_blank","toolbar=yes, scrollbars=yes, resizable=yes, width=500px,height=250px");
        </script>
         <?php   }
          
          ?>
        
                <form  name ="form" method="post">
                <input type="text" name="subdomain"/>
                <input type="submit" value="Continue" name="submit">
                </form>
        File 2 : win2.php(open in new window file and get value in this file)
        Code:
        <?php 
        
        $val = $_GET['val'];
        echo $val;
        
        ?>
        Last edited by hemal8888; Jan 29 '14, 09:59 AM. Reason: for url change

        Comment

        Working...