1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Having a form button open a new popup window?

Discussion in 'Web Design & Development' started by Leiki, Jul 28, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. Leiki

    Leiki Thread Starter

    Joined:
    Jul 15, 2005
    Messages:
    102
    I've found tutorials on how to make a regular form button open a popup window when clicked, but I have a "form action" button:

    Code:
    <form action="getin.php" method="post">
    <font size="2">Username:<input type="text" name="username" size="19"><br>
    Password:</font><input type="password" name="password" size="20"><br>
    <input type="submit" value="Login" name="submit">
    And I also have this code which I would like to use to create the popup window:

    Code:
    <a href="#" onClick="MyWindow=window.open('page.html','MyWindow','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=800,height=600,left=50,top=50'); return false;">Link Here</a>
    But I cannot find a way to incorporate that code into the form button, so the button can still communicate with getin.php and also have those popup attributes. How could I go about doing this? Thank you!
     
  2. face1

    face1

    Joined:
    Sep 16, 2005
    Messages:
    182
    place this in the top of page after <body> tag
    where *********************** is the url for newpage or for graphic


    <SCRIPT LANGUAGE="JAVASCRIPT">
    <!--
    function WinOpen() {
    open("*******************","Window1","width=500,height=330");
    }
    //-->
    </SCRIPT>

    ADD THIS

    <form action="getin.php" method="post" onClick="WinOpen()">
    <font size="2">Username:<input type="text" name="username" size="19"><br>
    Password:</font><input type="password" name="password" size="20"><br>
    <input type="submit" value="Login" name="submit">
     
  3. Leiki

    Leiki Thread Starter

    Joined:
    Jul 15, 2005
    Messages:
    102
    Thanks for the help face1, but that doesn't seem to work. Well it works, but it doesn't communicate with getin.php. Getin.php has a PHP code that checks if the information entered in the form matches any rows in my MySQL database (and then does a certain action if anything if found).

    The script you supplied (as well as others I've tried) only launches getin.php without doing anything mentioned above.
     
  4. face1

    face1

    Joined:
    Sep 16, 2005
    Messages:
    182
    using the same beginning script-
    try replacing

    <input type="submit" value="Login" name="submit">

    with

    <input type="image" border="0" name="imageField" src="********.gif" width="157" height="19" onClick="WinOpen1()">

    with an image (.jpg or .gif) where ******** is the filepath/name of the image in the script above and width & height are the size of the image

    maybe the separate location for the WinOpen command will help
     
  5. face1

    face1

    Joined:
    Sep 16, 2005
    Messages:
    182
    sorry! you will need to add the value="Login" line to the script as well.........
     
  6. Leiki

    Leiki Thread Starter

    Joined:
    Jul 15, 2005
    Messages:
    102
    Sorry, but this has nothing to do with replacing an image for the form button. I just want the button to send the form information to getin.php while opening the window into a new popup.
     
  7. face1

    face1

    Joined:
    Sep 16, 2005
    Messages:
    182
    replacing the button with an image allows the image to trigger the new window instead of the form action...it is a possibility (and therefore worth a try) that it will not interfere with the form action and the getin.php code check you are looking to accomplish.

    I am not familiar with getin.php you are using...just an educated (barely) guess
     
  8. Leiki

    Leiki Thread Starter

    Joined:
    Jul 15, 2005
    Messages:
    102
    Oh! I'm so sorry... I really appreciate your help. However it still does not work... The popup windows DOES work, but the actual logging process still goes on the current window of the form.

    Here is getin.php if that helps:

    PHP:
    <?php
    $conn 
    mysql_connect("localhost","root","root");
    $db mysql_select_db("database");

    $username $_POST["username"];
    $password $_POST["password"];

    $result MYSQL_QUERY("SELECT * from users WHERE username='$username'and password='$password'")
       or die (
    "Error");

    $worked mysql_fetch_array($result);

    $username $worked[username];
    $password $worked[password];
    $email $worked[email];

    if(
    $worked)
       
    header("Location: $username/");
       
    ?>
    Again, I'm very sorry.
     
  9. face1

    face1

    Joined:
    Sep 16, 2005
    Messages:
    182
    ....add value to script? as I clumsily added to the quick post? ...or notice my goofball mistake?

    ...please note erroneous onClick value of WinOpen1() has been changed to correct value of winOpen() ....bad typing strikes again....please re-try with corrected script and forgive the waste of time inconvenience my typo may have caused (1 finger typer!)

    <input type="image" border="0" name="imageField" src="setapart-graphics/hsguysbiblestudy.gif" width="157" height="19" onClick="WinOpen()" value="Login" >

    if nothing works still....then the loud wooshing sound you heard was the sound of things going very quickly over my head!!!!
     
  10. Leiki

    Leiki Thread Starter

    Joined:
    Jul 15, 2005
    Messages:
    102
    Yes, I did add value and I also took the 1 out of WinOpen(). Oh well. :( I still appreciate your help. Ok...anyone else? :D
     
  11. brendandonhu

    brendandonhu

    Joined:
    Jul 8, 2002
    Messages:
    14,681
    Code:
    <form action="getin.php" method="post" onsubmit="window.open('page.html','MyWindow','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=800,height=600,left=50,top=50');">
    <font size="2">Username:<input type="text" name="username" size="19"><br>
    Password:</font><input type="password" name="password" size="20"><br>
    <input type="submit" value="Login" name="submit">
     
  12. Leiki

    Leiki Thread Starter

    Joined:
    Jul 15, 2005
    Messages:
    102
    Thank you for your help brendandonhu, however the page.html is the one opened in the popup window while the logging in is taking place in the main window. I would like the main window to be left alone, and have the logging in taking place in the popup window. Can this be done? Thanks again.
     
  13. brendandonhu

    brendandonhu

    Joined:
    Jul 8, 2002
    Messages:
    14,681
    Code:
    <form action="getin.php" method="post" onsubmit="window.open('page.html','MyWindow','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resi
    zable=yes,width=800,height=600,left=50,top=50');" target="MyWindow">
    <font size="2">Username:<input type="text" name="username" size="19"><br>
    Password:</font><input type="password" name="password" size="20"><br>
    <input type="submit" value="Login" name="submit">
     
  14. Leiki

    Leiki Thread Starter

    Joined:
    Jul 15, 2005
    Messages:
    102
    Aha! Thank you VERY much!!
     
  15. brendandonhu

    brendandonhu

    Joined:
    Jul 8, 2002
    Messages:
    14,681
    [tsg=yourewelcome]yourewelcome[/tsg]
     
  16. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/487296

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice