Submit form to new window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terence Parker

    #1

    Submit form to new window

    How does one go about submitting a form with a link - but submitting
    it to a new window AND to a page different to that described within
    the action="" option of the <form> tag?

    Say, for example, I have a simple form such as the following:

    <form method="POST" action="submit. php" name="AForm">
    Name: <input type="text" name="Name" length="20"><br >
    Age: 15 <a href="age.php"> change age</a><br>
    <input type="submit" name="submit" value="submit">
    </form>

    Clicking 'submit' will submit to 'submit.php' - but I want the link to
    submit to 'age.php'.

    This example is an oversimplificat ion of what I want to do - yes, I
    know that in the example above I don't NEED to submit a link into a
    new window... But, it's an example.

    I know one can use ONCLICK="docume nt.formName.sub mit();return true;" -
    but that submits to the same form defined in <form action> .

    I know as well that I can use "onClick=window .open('link.php ','Popup
    Window','toolba r=no,
    location=no,dir ectories=no,sta tus=no,menubar= no,scrollbars=n o,
    resizable=no,co pyhistory=no,wi dth=500,height= 500,top=20,left =
    100')" (or something similar) to open a link to a new window.

    But how do I combine the two - AND submit to a different location?

    Basically, what i'm doing is one of those pages with customer
    information - and for one of those choices I want to popup a new
    window with a <select> . That submit will then send the data back to
    the originating PHP page - and will reload it.

    IDEALLY, I wouldn't even do it like this - just have javascript
    replace the values on the originating page without reloading (and
    resubmitting everything)... so if anyone knows how to do that, even
    better!

    Thanks,

    Terence
  • VK

    #2
    Re: Submit form to new window

    1. If you just want to open a new default window for output:
    <form action="submit. php" target="_blank" >

    2. If you want to redirect to a window with custom properties (size,
    position etc.):
    <script>
    function redirectOutput( myForm) {
    var w = window.open('ab out:blank','Pop up_Window','... params...');
    myForm.target = 'Popup_Window';
    return true;
    }
    </script>

    <form action="submit. php" onSubmit="redir ectOutput(this) ">
    ....
    </form>


    Terence Parker <terence@parker .com.hk> wrote in message
    news:a90f2173.0 310162057.483c0 348@posting.goo gle.com...[color=blue]
    > How does one go about submitting a form with a link - but submitting
    > it to a new window AND to a page different to that described within
    > the action="" option of the <form> tag?
    >
    > Say, for example, I have a simple form such as the following:
    >
    > <form method="POST" action="submit. php" name="AForm">
    > Name: <input type="text" name="Name" length="20"><br >
    > Age: 15 <a href="age.php"> change age</a><br>
    > <input type="submit" name="submit" value="submit">
    > </form>
    >
    > Clicking 'submit' will submit to 'submit.php' - but I want the link to
    > submit to 'age.php'.
    >
    > This example is an oversimplificat ion of what I want to do - yes, I
    > know that in the example above I don't NEED to submit a link into a
    > new window... But, it's an example.
    >
    > I know one can use ONCLICK="docume nt.formName.sub mit();return true;" -
    > but that submits to the same form defined in <form action> .
    >
    > I know as well that I can use "onClick=window .open('link.php ','Popup
    > Window','toolba r=no,
    > location=no,dir ectories=no,sta tus=no,menubar= no,scrollbars=n o,
    > resizable=no,co pyhistory=no,wi dth=500,height= 500,top=20,left =
    > 100')" (or something similar) to open a link to a new window.
    >
    > But how do I combine the two - AND submit to a different location?
    >
    > Basically, what i'm doing is one of those pages with customer
    > information - and for one of those choices I want to popup a new
    > window with a <select> . That submit will then send the data back to
    > the originating PHP page - and will reload it.
    >
    > IDEALLY, I wouldn't even do it like this - just have javascript
    > replace the values on the originating page without reloading (and
    > resubmitting everything)... so if anyone knows how to do that, even
    > better!
    >
    > Thanks,
    >
    > Terence[/color]


    Comment

    • Stephen

      #3
      Re: Submit form to new window

      Hi Terence,

      Terence Parker wrote:[color=blue]
      > How does one go about submitting a form with a link - but submitting
      > it to a new window AND to a page different to that described within
      > the action="" option of the <form> tag?
      >[/color]

      I'm a little confused here ... You always submit to a web server and
      you submit to the action="" uri. The returned content can be directed to
      another window.
      [color=blue]
      > Say, for example, I have a simple form such as the following:
      >
      > <form method="POST" action="submit. php" name="AForm">
      > Name: <input type="text" name="Name" length="20"><br >
      > Age: 15 <a href="age.php"> change age</a><br>
      > <input type="submit" name="submit" value="submit">
      > </form>
      >
      > Clicking 'submit' will submit to 'submit.php' - but I want the link to
      > submit to 'age.php'.
      >[/color]

      If you want to submit to "age.php", why put "submit.php " as the value of
      the action attribute? Put "age.php" there.
      [color=blue]
      > This example is an oversimplificat ion of what I want to do - yes, I
      > know that in the example above I don't NEED to submit a link into a
      > new window... But, it's an example.
      >
      > I know one can use ONCLICK="docume nt.formName.sub mit();return true;" -
      > but that submits to the same form defined in <form action> .
      >[/color]

      That's what it's supposed to do. Now, I do believe you can set the value
      of action dynamically, something like

      document.forms["formName"].action="uri";

      before doing the submit...

      [color=blue]
      > I know as well that I can use "onClick=window .open('link.php ','Popup
      > Window','toolba r=no,
      > location=no,dir ectories=no,sta tus=no,menubar= no,scrollbars=n o,
      > resizable=no,co pyhistory=no,wi dth=500,height= 500,top=20,left =
      > 100')" (or something similar) to open a link to a new window.
      >
      > But how do I combine the two - AND submit to a different location?
      >
      > Basically, what i'm doing is one of those pages with customer
      > information - and for one of those choices I want to popup a new
      > window with a <select> . That submit will then send the data back to
      > the originating PHP page - and will reload it.
      >
      > IDEALLY, I wouldn't even do it like this - just have javascript
      > replace the values on the originating page without reloading (and
      > resubmitting everything)... so if anyone knows how to do that, even
      > better!
      >[/color]
      Ah .. so we finally get to what the real need is. I think this last idea
      is probably best; forget that popping up of extra windows. If you can do
      it without the popups, good. If you can dynamically update the page
      without making a round trip to the server, that's probably better, too.

      For myself, I'd rather see you post some code with the specifics of what
      you want in the <select> and what you'd like to see happen when the user
      selects something. That might give a better starting point for advice
      that can contribute to the solution that you'd ideally like to implement.

      Regards,
      Stephen

      Comment

      Working...