Professional Web Applications Themes

CGI script with target in the body - PERL Modules

Hey ho. I have a form with two different submit buttons. When button A is pressed, I want the new page opened in a new window, but not when button B is pressed. Unfortunately, submit buttons don't seem to pay attention to target attributes. So I thought I'd let my script set the target attribute after the button is pushed (it's easy to know which button was pressed). So, I put "-target => '_blank'" in the arguments for start_html. But that's no good, I'm afraid. The CGI module sticks that attribute in the <base> tag instead of the <body> tag. ...

  1. #1

    Default CGI script with target in the body

    Hey ho.

    I have a form with two different submit buttons. When button A is
    pressed, I want the new page opened in a new window, but not when
    button B is pressed. Unfortunately, submit buttons don't seem to pay
    attention to target attributes.

    So I thought I'd let my script set the target attribute after the
    button is pushed (it's easy to know which button was pressed). So, I
    put "-target => '_blank'" in the arguments for start_html.

    But that's no good, I'm afraid. The CGI module sticks that attribute
    in the <base> tag instead of the <body> tag. Dammit.

    Any ideas how to force that argument to go to the body tag?

    Thanks.

    (Note that I've crossposted, since I'm not sure what group is
    appropriate.)
    --
    Jesse F. Hughes

    "Would you please stop talking and start talking?"
    -- Vincent Price as the Saint
    Jesse F. Hughes Guest

  2. #2

    Default Re: OT CGI script with target in the body

    Jesse F. Hughes wrote:
    > I have a form with two different submit buttons. When button A is
    > pressed, I want the new page opened in a new window, but not when
    > button B is pressed. Unfortunately, submit buttons don't seem to pay
    > attention to target attributes.
    Try onsubmit / windows.open.
    > (Note that I've crossposted, since I'm not sure what group is
    > appropriate.)
    No Perl group is (the other group does not exist AFAIK). You should
    probably have asked in an HTML or JavaScript group.

    --
    Gunnar Hjalmarsson
    Email: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]
    Gunnar Hjalmarsson Guest

  3. #3

    Default Re: CGI script with target in the body

    On Wed, 17 Aug 2005 10:26:09 +0200, Jesse F. Hughes wrote:
    > I have a form with two different submit buttons. When button A is
    > pressed, I want the new page opened in a new window, but not when
    > button B is pressed. Unfortunately, submit buttons don't seem to pay
    > attention to target attributes.
    >
    > So I thought I'd let my script set the target attribute after the
    > button is pushed (it's easy to know which button was pressed). So, I
    > put "-target => '_blank'" in the arguments for start_html.
    I think an <input type="button" target="foo"> tag might work instead of
    a submit button. At times I've set the value option on submit buttons so
    a script could tell which button was pressed.

    --
    Stephen Patterson [email]stevepatter.mine.nu[/email] [url]http://patter.mine.nu/[/url] GPG: E3E8E974
    Jabber: patter on jabber.earth.li MSN: [email]stephenpatterson893hotmail.com[/email]
    "Whoever said nothing is impossible never tried slamming a revolving door."
    -- Melissa O'Brien
    Stephen Patterson Guest

  4. #4

    Default Re: OT CGI script with target in the body

    Gunnar Hjalmarsson <noreplygunnar.cc> writes:
    > Jesse F. Hughes wrote:
    >> I have a form with two different submit buttons. When button A is
    >> pressed, I want the new page opened in a new window, but not when
    >> button B is pressed. Unfortunately, submit buttons don't seem to pay
    >> attention to target attributes.
    >
    > Try onsubmit / windows.open.
    But I have two submit buttons. I only want a new window when button A
    is pressed. Isn't onsubmit a <form> attribute?

    onSubmit
    The user has pressed the submit button of a form. This
    event happens just before the form is submitted, and
    your function can return a value of false in order to
    abort the submission. Valid for:

    + Forms only.

    Oh wait. I get it. I can write a little javascript code to see which
    button was pressed, right? I'll see if I can't do that.

    But from my perspective, the less javascript the better. I like using
    perl more than javascript. Not sure why. Maybe it's because I prefer
    server-side scripting.
    >> (Note that I've crossposted, since I'm not sure what group is
    >> appropriate.)
    >
    > No Perl group is (the other group does not exist AFAIK). You should
    > probably have asked in an HTML or JavaScript group.
    Okay, thanks.
    --
    Jesse F. Hughes

    "I want to really eat myself, so then I'll be a coalgebra."
    -- Quincy P. Hughes, Age 3 1/2
    Jesse F. Hughes Guest

  5. #5

    Default Re: CGI script with target in the body

    Stephen Patterson <stevepatter.mine.nu> writes:
    > On Wed, 17 Aug 2005 10:26:09 +0200, Jesse F. Hughes wrote:
    >
    >> So I thought I'd let my script set the target attribute after the
    >> button is pushed (it's easy to know which button was pressed). So, I
    >> put "-target => '_blank'" in the arguments for start_html.
    >
    > I think an <input type="button" target="foo"> tag might work instead of
    > a submit button. At times I've set the value option on submit buttons so
    > a script could tell which button was pressed.
    I didn't really try that, since I need the form values to be passed
    too. I thought that the form values are passed only if it's a submit
    button, but I'm not sure. I should look into it.

    Thanks for the suggestion.

    --
    Jesse F. Hughes
    "A gorgeous display of homoerotic lust."
    -- Review blurb found on the back of a
    Chinese black market "Dawn of the Dead" DVD
    Jesse F. Hughes Guest

  6. #6

    Default Re: OT CGI script with target in the body

    Jesse F. Hughes wrote:
    > Gunnar Hjalmarsson writes:
    >> Try onsubmit / windows.open.
    >
    > But I have two submit buttons. I only want a new window when button A
    > is pressed. Isn't onsubmit a <form> attribute?
    Maybe you need two forms. Clumsy, but...

    --
    Gunnar Hjalmarsson
    Email: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]
    Gunnar Hjalmarsson Guest

  7. #7

    Default Re: OT CGI script with target in the body

    Gunnar Hjalmarsson <noreplygunnar.cc> writes:
    > Jesse F. Hughes wrote:
    >> Gunnar Hjalmarsson writes:
    >>> Try onsubmit / windows.open.
    >> But I have two submit buttons. I only want a new window when button
    >> A
    >> is pressed. Isn't onsubmit a <form> attribute?
    >
    > Maybe you need two forms. Clumsy, but...
    I'm not sure that works for me.

    Maybe I should explain. I have a form for creating a database entry
    that includes a search string for selecting certain records from a
    different database.

    Submit button one is to check the results of the search, so that the
    user knows he's entered the right data before he adds it to the
    database.

    Submit button two is to add it to the database.

    Both buttons need the information from the same form. It is slightly
    preferable if button one opens a new window for displaying the search
    results, so that the form is still present at all times. (For
    technical reasons, I don't want to have to use the back arrow to
    re-display the form.)

    Thanks for the suggestions.
    --
    Jesse F. Hughes
    "Certainly he who can digest a second or third fluxion need
    not, methinks, be squeamish about any point in divinity."
    George Berkeley, 1734
    Jesse F. Hughes Guest

  8. #8

    Default Re: OT CGI script with target in the body

    "Jesse F. Hughes" <jessephiwumbda.org> wrote:
    > Gunnar Hjalmarsson <noreplygunnar.cc> writes:
    >
    > > Jesse F. Hughes wrote:
    > >> Gunnar Hjalmarsson writes:
    > >>> Try onsubmit / windows.open.
    > >> But I have two submit buttons. I only want a new window when button
    > >> A
    > >> is pressed. Isn't onsubmit a <form> attribute?
    > >
    > > Maybe you need two forms. Clumsy, but...
    >
    > I'm not sure that works for me.
    >
    > Maybe I should explain. I have a form for creating a database entry
    > that includes a search string for selecting certain records from a
    > different database.
    >
    > Submit button one is to check the results of the search, so that the
    > user knows he's entered the right data before he adds it to the
    > database.
    >
    > Submit button two is to add it to the database.
    >
    > Both buttons need the information from the same form. It is slightly
    > preferable if button one opens a new window for displaying the search
    > results, so that the form is still present at all times. (For
    > technical reasons, I don't want to have to use the back arrow to
    > re-display the form.)
    Make use of the sticky-fields feature of CGI.pm. Have button one perform
    the search, display the results of that search, and then re-display the
    form (already filled out) for further action.

    Xho

    --
    -------------------- [url]http://NewsReader.Com/[/url] --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
    xhoster@gmail.com Guest

  9. #9

    Default Re: OT CGI script with target in the body

    [email]xhoster[/email] writes:
    >> Both buttons need the information from the same form. It is slightly
    >> preferable if button one opens a new window for displaying the search
    >> results, so that the form is still present at all times. (For
    >> technical reasons, I don't want to have to use the back arrow to
    >> re-display the form.)
    >
    > Make use of the sticky-fields feature of CGI.pm. Have button one perform
    > the search, display the results of that search, and then re-display the
    > form (already filled out) for further action.
    Yes, that's an option. I've done something similar in another
    context.

    The only problem is (you knew it was coming)... it's not so visually
    appealing in this case. The first button finds matching photos from
    a database and displays thumbnails for up to the first 40 of them
    (with buttons to page through all of the photos). It's just a bit
    inconvenient to place a form below that (and even then, the user may
    want to alter his search parameters and re-display the results before
    updating, so I'd still need *both* buttons).

    Thanks for another good suggestion. I'll mull it over a bit.

    Really, this form is only used by my wife and me anyway. I'm a bit
    embarrassed to admit that, given how many good suggestions I've
    rejected so far.
    --
    Jesse F. Hughes
    "I love Mathematics[...] She doesn't care about my feelings, or my
    pride or how I so wish to get out and travel. Truth is truth, and
    anything else is just plain wrong." -- James Harris, /A Love Story/
    Jesse F. Hughes Guest

  10. #10

    Default Re: CGI script with target in the body

    Jesse F. Hughes wrote:
    > Hey ho.
    >
    > I have a form with two different submit buttons. When button A is
    > pressed, I want the new page opened in a new window, but not when
    > button B is pressed. Unfortunately, submit buttons don't seem to pay
    > attention to target attributes.
    The HTML standard does not have TARGET= as valid for submit buttons.

    It's not the submit buttons that control the target frame, it's the
    <form action="..." target="_blank">
    tag. Two actions = two separate forms.
    Joe Smith Guest

  11. #11

    Default Re: OT CGI script with target in the body

    "Jesse F. Hughes" <jessephiwumbda.org> writes:
    > [email]xhoster[/email] writes:
    >
    >>> Both buttons need the information from the same form. It is slightly
    >>> preferable if button one opens a new window for displaying the search
    >>> results, so that the form is still present at all times. (For
    >>> technical reasons, I don't want to have to use the back arrow to
    >>> re-display the form.)
    >>
    >> Make use of the sticky-fields feature of CGI.pm. Have button one perform
    >> the search, display the results of that search, and then re-display the
    >> form (already filled out) for further action.
    >
    > Yes, that's an option. I've done something similar in another
    > context.
    >
    > The only problem is (you knew it was coming)... it's not so visually
    > appealing in this case. The first button finds matching photos from
    > a database and displays thumbnails for up to the first 40 of them
    > (with buttons to page through all of the photos). It's just a bit
    > inconvenient to place a form below that (and even then, the user may
    > want to alter his search parameters and re-display the results before
    > updating, so I'd still need *both* buttons).
    You could store the last entry somewhere when the "preview" button is
    pressed, then have the "save" button just use that last entry (which
    would let you use a seperate form for it). You could save it
    client-side in a cookie, or server-side in session file. It can break
    if there are multiple windows with the same client or session
    simultaneously previewing and saving different parts of the database,
    so if that sort of thing might happen you'll need to take special
    care.

    Another option is to digest the first results, save them in CGI
    fields and redisplay, then have a link on the second page that says
    "preview changes in new window" that will pass along those parameters
    to a preview script, and also a button that says "Save" that passes
    along the same parameters to a save script.

    ----Scott.
    Scott W Gifford Guest

  12. #12

    Default Re: CGI script with target in the body

    Joe Smith wrote:
    > Jesse F. Hughes wrote:
    >> Hey ho.
    >>
    >> I have a form with two different submit buttons. When button A is
    >> pressed, I want the new page opened in a new window, but not when
    >> button B is pressed. Unfortunately, submit buttons don't seem to pay
    >> attention to target attributes.
    >
    > The HTML standard does not have TARGET= as valid for submit buttons.
    >
    > It's not the submit buttons that control the target frame, it's the
    > <form action="..." target="_blank">
    > tag. Two actions = two separate forms.
    have a look at the <button></button> tag.
    --
    [url]http://www.gregerhaga.net[/url]
    Greger Guest

Similar Threads

  1. TARGET PLEASE
    By nivla17 in forum Coldfusion Flash Integration
    Replies: 6
    Last Post: August 11th, 09:05 PM
  2. Ereg: select all text between <BODY> </BODY> tags..
    By Hi Ho in forum PHP Development
    Replies: 4
    Last Post: January 30th, 01:14 PM
  3. Replies: 1
    Last Post: October 14th, 08:10 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139