SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2002
    Location
    Newcastle, UK
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Function to open a new window with variables attached to url?

    Hi -

    I'm figuring this will need to be done in a function. I'm building a page builder with 2 fields, a textbox called 'title' and a textarea called 'text' (imaginative huh!).

    I want to have a preview facility. I've built the preview page, all I want to do is have a javascript button that passes the value of those two text fields to this preview page in the querystring. Is there a way using variables to pass this through??

    I also have the preview page set up to receive the variables in the querystring.

    Any ideas?
    E

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Why not just change the value of the form's action attribute, and tell it to submit in a new window? Something like this:

    JavaScript:
    Code:
    function previewPost(f) {
      //f is the form's name
      //alter the settings in window.open at will
      f.action = "preview.php";
      window.open("about:blank", "Preview", "width=500, height=320");
      f.target = "Preview";
      f.submit();
    }
    HTML:
    HTML Code:
    <input type="button" value="Preview Post" onclick="previewPost(this.form);" />

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2002
    Location
    Newcastle, UK
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers vgarcia - yep, could do - should have explained though - I need to have it seperate from the form as the form inserts the record into the database, can I still pass the content of the two text fields through to the preview page though?

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by entropy
    Cheers vgarcia - yep, could do - should have explained though - I need to have it seperate from the form as the form inserts the record into the database, can I still pass the content of the two text fields through to the preview page though?
    Yeah. Actually, that Preview Post button should be on your form in ADDITION to your submit button. Your submit button will carry on normal insert operations in the main window, but the Preview button will do whatever it needs in that second window.

  5. #5
    SitePoint Zealot
    Join Date
    Jun 2002
    Location
    Newcastle, UK
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Vinnie - see where you're coming from now. OK, I've set it up and it's opening up the new window etc., just having a bit of trouble with the function:

    The target page is ../../preview_page.asp - and that page is set up to receive the variables from the querystring, what do I need to change in the preview page, and in the function?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •