SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru DeNasio's Avatar
    Join Date
    May 2001
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Displaying form ouput in popup window

    Hello,

    I use the following code to display the results of a form in a popup window:

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    function Start(page)
    {OpenWin = this.open(page,"popup","scrollbars=1,top=50,left=100,width=560,height=450");}
    </SCRIPT>
    <FORM ACTION="form.php" METHOD="POST" TARGET="popup">
    .
    .
    .
    <INPUT TYPE="submit" VALUE="Submit Vote" OnClick="Start('')">
    </FORM>
    I copied this code a few years ago from a site. It appears to be working fine, but I'm not sure if the syntax is correct. I have 2 questions:

    - Is the TARGET="popup" required here?
    - Is OnClick="Start('')" correct? Shouln't it be OnClick="Start(this.form)" or something like that?
    Ballot-Box.net - free polls for webmasters
    FormLog.com - free form processor

  2. #2
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hm, personally I'd put the Onclick as an onsubmit on the form tag, but you suit yourself.

    Uh, from what it looks, the Start fuctoin should have a URL passed to it, or a file for the page to popup.

    Regards,
    Someonewhois

  3. #3
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    from a strict javascript point of view:
    Based on the code you posted -- it shouldn't work.
    1) function Start(page) -- at no point is there an assignment to the var page
    2) onclick="Start(' ')" -- you are not passing anything

    The only reasons it can be working is:
    1) page is a field value being passed to the php script
    2) the php script is passing the variable to the function.

    It just gives more credance to saying: Don't fix what isn't broke

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  4. #4
    SitePoint Guru DeNasio's Avatar
    Join Date
    May 2001
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Vincent Puglia
    Hi,
    from a strict javascript point of view:
    Based on the code you posted -- it shouldn't work.
    1) function Start(page) -- at no point is there an assignment to the var page
    2) onclick="Start(' ')" -- you are not passing anything
    This is not true.

    onclick="Start(' ')" creates an "empty" popup window named "popup".
    And <FORM TARGET="popup"> sends the form output to the popup window named "popup".

    I know this works, but I was wondering if there was a more elegant way to do this.
    Last edited by DeNasio; Sep 7, 2003 at 11:17.
    Ballot-Box.net - free polls for webmasters
    FormLog.com - free form processor


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
  •