473,396 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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:

Expand|Select|Wrap|Line Numbers
  1.     <form 
  2.     onsubmit="window.location='http://'+this.subdomain.value+'.myurl.com/';
  3.  return false" target="_blank">
  4.     <input type="text" name="subdomain"/>
  5.     <input type="submit" value="Continue">
  6.     </form>
I replace my actual URL with 'myurl' for the purpose of this post.


Any suggestions?
Thanks
Jan 25 '14 #1
3 3648
Claus Mygind
571 512MB
Use window.open() instead of window.location. Open always opens a new window and can take parameters.

read more about it here
Jan 27 '14 #2
Hi,
if you open the new window mean try do this
Expand|Select|Wrap|Line Numbers
  1. window.open("Your url","_blank","toolbar=yes, scrollbars=yes, resizable=yes,");
Jan 29 '14 #3
Hii In Below i have put completed code in php it is completely testing by me
File 1 : wino.php
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.    if(isset($_POST['submit']))
  3.    {
  4.        $val = $_POST['subdomain'];
  5.  ?>
  6.  <script>
  7. window.open("http://localhost/win2.php?val=<?php echo $val; ?>","_blank","toolbar=yes, scrollbars=yes, resizable=yes, width=500px,height=250px");
  8. </script>
  9.  <?php   }
  10.  
  11.   ?>
  12.  
  13.         <form  name ="form" method="post">
  14.         <input type="text" name="subdomain"/>
  15.         <input type="submit" value="Continue" name="submit">
  16.         </form>
  17.  
  18.  
File 2 : win2.php(open in new window file and get value in this file)
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.  
  3. $val = $_GET['val'];
  4. echo $val;
  5.  
  6. ?>
Jan 29 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ben | last post by:
Hi there, in a form, here's what I want to do : <input type=button onclick= (???) is it possible to open a pop-up window with a specified url without using javascript ? Thanks
3
by: Nick | last post by:
Should be a quickie but I just can't get it to work. I have a form where my users can submit their football picks, when they click submit I would like another sized window to appear...
1
by: Matt | last post by:
My problem is when the user click the submit button, it will launch another new window for the request page. I want to confirm we cannot use JavaScript open window functions to open a request page?...
1
by: Paul Oakfleet | last post by:
The script below will disable Submit button until user accept terms, and will redirect user to another page after clicking on Submit button. The script seems to work fine on my PC (Windows XP,...
2
by: jrefactors | last post by:
The following will submit the form data to popup by clicking the submit button. I want it will submit the form automatically to the popup, there is no submit button in this page. Basically this...
2
by: Hongyu | last post by:
I am trying to implement a simple JavaScript of redirecting my window to a new URL upon clicking a submit button. This is an easy task except when I have to put an input type='submit' in front of...
2
by: Cheryl | last post by:
Hi, I have encounter a problem.Language use is C#. I would like to open a new window (is a modal window, where I m not able to switch from parent window after this window is open)from the parent...
2
by: Ghafran Abbas | last post by:
Call this function from the Page_OnLoad event of your asp.net page. This will prevent the user from doing multiple post backs or button clicks. This was designed to not disable the button, because...
3
by: Jeff | last post by:
I have a payment form with a submit button. A large percentage of users double-click the submit button thus submitting their payment information twice. I would like to use javascript to disable...
7
by: Bjorn Sagbakken | last post by:
Hello. There maybe an simple answer to this, but sometimes one get a strange blindness when working intensely on one single problem. I'm using ASP.NET 2003, building pages that include 3 user...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.