Thread: pop-up windows

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    Canada
    Posts
    35
    Rep Power
    15
    Hi guys,
    I have a form coded as:
    <form action="test.php" method="post">
    the form has two buttons: Preview and Submit

    test.php:
    if ($Preview) {// perform action 1}
    else {// perform action2}

    My question: If Preview is clicked, I would like to open a new pop-up window without closing the original one. I would like the results of action 1 to be displayed on this new pop-up window.
    Is there a way to do that without using javascript?
    If no, then how would you do that with javascript???

    NB: i cannot use target=_blank in the form tag because i would like to have the pop-up window only if Preview is selected.
    But maybe there is a better way to code everything!

    thanks in advance!

  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4476
    You'd have to do this with javascript.


    <input type="button" value="Preview" onclick="window.open('http://www.you.com/preview.php');">
    <input type="button" value="Submit" onclick="window.open('http://www.you.com/submit.php');">

    maybe it's window.new instead of open. i'm not sure on that syntax either, read up on it. but that's how you'd have to do it. you could use a function to create some hidden variables to pass a long to the next page, also.

    ---John Holmes...
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Pune, Maharashtra, India
    Posts
    86
    Rep Power
    14
    Yes this can easily be done using JAVASCRIPT
    TO open a new window use following code:
    <Input type="button" value="Preview" onClick="window.open('http://myserver/myfile.php')">
    This will open a new page. Hope this helps.



    ------------------
    Nikunj Virani
    MYSQL/PHP/XML
    This is the world of Nikunj
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    Canada
    Posts
    35
    Rep Power
    15
    Thanks guys!
    However I got this problem (everything was working fine before inserting the javascript command):
    first of all, i don't have two files preview.php and submit.php. The two buttons are linked to a unique test.php file.
    in test.php. I am first checking whether all mandatory fields have been filled.
    if ($first==""){//error message}
    .
    .
    .
    else{
    if (Preview){// perform action 1}
    else {// perform action2}
    }

    Now, in my form I have:
    <form action="test.php" method="post">
    <Input type="button" value="Preview" onClick="window.open('http://myserver/test.php')">
    <Input type="button" value="Submit">

    when I click on Preview i get the new window, however in this new window I get the error message because if ($first=="") returns true (but the field 'first' is filled!)
    and the action1 is performed on the original window, not on the pop-up one!

    Do you know what's going on?????
    i hope this makes sense to you...

Similar Threads

  1. URL with bookmark on close spawns multiple pop up windows
    By Lalita in forum Beginner Programming
    Replies: 4
    Last Post: February 3rd, 2004, 10:11 PM
  2. Replies: 2
    Last Post: January 30th, 2004, 12:02 AM
  3. unique size pop up windows
    By plastic_chai in forum HTML Programming
    Replies: 12
    Last Post: January 13th, 2004, 08:29 PM
  4. pop up windows
    By dakillerspyder in forum HTML Programming
    Replies: 2
    Last Post: November 17th, 2003, 02:20 AM
  5. samba 2.2 shares "taking over" windows shares
    By nspeed in forum Networking Help
    Replies: 0
    Last Post: October 28th, 2003, 04:21 PM

IMN logo majestic logo threadwatch logo seochat tools logo