SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    One form, two submit buttons. How to (optionally) submit to new window?

    Is it possible to have two submit buttons on a form, and depending on which button is clicked, have the form submit to a new window?

    For example, let's say I have a form with a bunch of input text tags and two submit buttons called "new window" and "same window".

    If I submit the form by clicking "new window", then I need the form to be submitted and the results displayed in a new window. If I submit the form by clicking "same window", then the form would be submitted as usual into the same window.

    I suspect this can be done with some javascript or something... does anyone know how to do this? (Or point me in the right direction?)

    Thanks!
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!

  2. #2
    SitePoint Wizard Ian Glass's Avatar
    Join Date
    Oct 2001
    Location
    Beyond yonder
    Posts
    2,384
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <input type="button" value="New Window"
     onclick="document.myForm.target='_new';
              document.myForm.submit();"/>
    I'm hardly a JS expert, however, I think that's down the right path--it probably still wont work though! :-p

    Basically, I'm attempting to dynamically change the target attribute on the form to open a new window, and then submit the form with the new target intact. You'd probably have to use an XHTML (or HTML if you're into that sorta' thing) transitional Doctype.

    Hope this helps, and someone comes along to correct my plethora mistakes... ;-)

    ~~Ian

  3. #3
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Moved to a more appropriate forum

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature


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
  •