#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    8
    Rep Power
    0

    Javascript/PHP Open New Window


    I have an html page that allows an end user to enter some data. I have the typical Submit button but this time I have also added a Preview submit button.

    I want to have it so when they hit the preview button it'll call the same script as the submit button does but instead of opening a full sized new window I want it to open a smaller window. I know the window.open method in Javascript but I am not sure how to exactly set this up..

    PHP Code:
      <form method=post action="addnews.php">
        
    // All Form Objects, Textboxes etc.
      
    <input type="Submit" name="Submit" value="Submit">
      <
    input type="Submit" name="Submit" value="Preview">
     </
    form
    addnews.php has an if statement to check what value was chosen

    If ($Submit == "Submit")
    add_to_database();
    Else // Must Be Preview
    preview_function();
    Last edited by Get Powered; September 29th, 2002 at 03:04 PM.
  2. #2
  3. No Profile Picture
    Senior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    8
    Rep Power
    0
    Hi powered,

    I don't know which is the desire one but in your case from what I see in your code, you can change the name of your button. Say:

    PHP Code:

    form method
    =post action="addnews.php">
        
    // All Form Objects, Textboxes etc.
      
    <input type="Submit" name="Submit" value="Submit">
      <
    input type="Submit" name="Preview" value="Preview">
     </
    form 
    So in your form processor, you just need to get the post for $_POST['Submit'] or $_POST['Preview'] in which case is valid and process your desire code.

    As what you wanted to do now, its a js question. Anyway try this bit, if its not working try posting this code to js forum.

    PHP Code:

    function newWindow() {

    window.open("verify.php?your_variable="+your_variable.value"""width=400,height=500,top=50,left=280,
    resizable,toolbar,scrollbars,menubar,"
    );
    }

    <
    input type=submit  name="submit" value="Preview" onClick="newWindow();"
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    8
    Rep Power
    0
    Well I was hoping to open the addnews.php script in a new smaller window when the preview button was clicked and open addnews.php in a normal size window when the submit button was clicked. I was using addnews.php to check and see what action to take.

    I was also hoping to open the window without having to pass all the variables through the url. I was just hoping to let Post Vars to take care of it within the PHP script.

    Not really sure if this is all possible.

IMN logo majestic logo threadwatch logo seochat tools logo