submit form values with openWindow

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin Nadoll

    submit form values with openWindow

    Hello

    i have a form, where my users can choose a postal code and a city to see a
    table result page with only entries of their choice.

    this results have to be shown in a new window :

    var firstLink = unescape(firstU RL.cfm');
    var secondLink = unescape(second URL.cfm');
    var thirdLink = unescape(thirdU RL.cfm');

    var myFormLink = unescape(formre sultURL.cfm');

    function popUpWindow(URL Str, left, top, width, height)
    {
    if(popUpWin)
    {
    if(!popUpWin.cl osed) popUpWin.close( );
    }
    popUpWin = open(URLStr, 'popUpWin',
    'toolbar=no,loc ation=no,direct ories=no,status =no,menub
    ar=no,scrollbar s,resizable=no, copyhistory=yes ,width='+width+ ',height='+heig h
    t+',left='+left +', top='+top+',scr eenX='+left+',s creenY='+top+'' );
    }

    html:

    <A HREF="firstLink " onClick="popUpW indow(firstLink , 40, 42, 790, 450);
    return false">here my first link</A>
    <A HREF="secondLin k" onClick="popUpW indow(secondLin k, 40, 42, 790, 450);
    return false">here my second link</A>
    <A HREF="thirdLink " onClick="popUpW indow(thirdLink , 40, 42, 790, 450);
    return false">here my third link</A>

    Now the problem:
    <form name="Firmenlis te" method="post" action="Schnell suche"
    onSubmit="popUp Window(myFormLi nk, 20, 20, 750, 400); return false">
    <input name="any1" type="text" id="any1">
    <input name="any2" type="text" id="any2">
    <input name="Submit" type="submit" id="Submit" value="OK">
    </form>

    This opens formresultURL.c fm in a new window, as expected, but the new
    window didn't receive the values of any1 and any2...

    Any idea, how i can solve that problem?

    Thanks a lot for any help and sorry for that long description of my problem,
    but i want to make it as clear as possible.

    Martin Nadoll


  • Guido Wesdorp

    #2
    Re: submit form values with openWindow

    Martin Nadoll wrote:
    [color=blue]
    > <form name="Firmenlis te" method="post" action="Schnell suche"
    > onSubmit="popUp Window(myFormLi nk, 20, 20, 750, 400); return false">
    > <input name="any1" type="text" id="any1">
    > <input name="any2" type="text" id="any2">
    > <input name="Submit" type="submit" id="Submit" value="OK">
    > </form>
    >[/color]
    window.open can not be used as the action for a form, to solve this you
    can either use 'target="_blank "' on the form tag to open a new window on
    form submit (should work afaik) or add the key/value pairs to the URL as
    'GET' vars: 'http://foo.com/mydoc.html?foo= bar&bar=baz' will send
    'foo=bar' and 'bar=baz' to mydoc.html. Take care of encoding chars
    whenever necessary using the escape function...

    Cheers,

    Guido

    Comment

    • Michael Winter

      #3
      Re: submit form values with openWindow

      Martin Nadoll wrote on 24 Nov 2003:

      <snip>
      [color=blue]
      > popUpWin = open(URLStr, 'popUpWin',
      > 'toolbar=no,loc ation=no,direct ories=no,status =no,menub
      > ar=no,scrollbar s,resizable=no, copyhistory=yes ,width='+width+ ',hei
      > ght='+heigh t+',left='+left +',
      > top='+top+',scr eenX='+left+',s creenY='+top+'' );
      > }[/color]

      It would have been nice if you split that string into concatenated
      sections, rather than letting it wrap - it would have been easier to
      test.

      <snip>
      [color=blue]
      > <form name="Firmenlis te" method="post" action="Schnell suche"
      > onSubmit="popUp Window(myFormLi nk, 20, 20, 750, 400); return
      > false">[/color]

      Your onsubmit event handler unconditionally cancels the submission.
      The 'successful controls' won't be submitted unless you allow it,
      whether that be through a call to Form.submit(), or returning true.

      I think that using a pop-up and the 'post' method would be quite
      difficult, and using 'get' might be a better alternative (depending
      on the content of the submission). An alternative would be to use a
      redirection page that opens in the current window, opens a pop-up
      with the results, then takes the main window back to the form, or
      another destination.

      Mike

      --
      Michael Winter
      M.Winter@blueyo nder.co.uk.invalid (remove ".invalid" to reply)

      Comment

      • Michael Winter

        #4
        Re: submit form values with openWindow

        [This may result in a double post. Apologies if so.]

        Martin Nadoll wrote on 24 Nov 2003:

        <snip>
        [color=blue]
        > popUpWin = open(URLStr, 'popUpWin',
        > 'toolbar=no,loc ation=no,direct ories=no,status =no,menub
        > ar=no,scrollbar s,resizable=no, copyhistory=yes ,width='+width+ ',hei
        > ght='+heigh t+',left='+left +',
        > top='+top+',scr eenX='+left+',s creenY='+top+'' );
        > }[/color]

        It would have been nice if you split that string into concatenated
        sections, rather than letting it wrap - it would have been easier to
        test.

        <snip>
        [color=blue]
        > <form name="Firmenlis te" method="post" action="Schnell suche"
        > onSubmit="popUp Window(myFormLi nk, 20, 20, 750, 400); return
        > false">[/color]

        Your onsubmit event handler unconditionally cancels the submission.
        The 'successful controls' won't be submitted unless you allow it,
        whether that be through a call to Form.submit(), or returning true.

        I think that using a pop-up and the 'post' method would be quite
        difficult, and using 'get' might be a better alternative (depending
        on the content of the submission). An alternative would be to use a
        redirection page that opens in the current window, opens a pop-up
        with the results, then takes the main window back to the form, or
        another destination.

        Mike

        --
        Michael Winter
        M.Winter@blueyo nder.co.uk.invalid (remove ".invalid" to reply)


        --
        Michael Winter
        M.Winter@blueyo nder.co.uk.invalid (remove ".invalid" to reply)

        Comment

        Working...