showModalDialog and submit

Discussion in 'ASP General' started by Joel, Nov 25, 2003.

  1. Joel

    Joel Guest

    Hi there,

    My original window (A) opens a modal dialog window (B).
    In B, you fill out a form and submit it to itself for
    processing. When B reloads, it knows that is successfully
    processed the form and it suppose to close itself after
    returning "1" or "0" to A.

    My problem is that B will never close. When I submit it,
    it kind of opens a new window and close that one before
    return to itself (B).

    Here is a code sample:

    A
    ---
    function newEntry(){
    var sReturn=window.showModalDialog('b.asp');
    alert(sReturn);
    }

    B
    ---
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <%
    dim bSave

    bSave=Request.QueryString("save")
    if bSave="1" then
    'process
    end if
    %>
    ....
    function init(bSave){
    if(bSave=='1'){
    window.returnValue=bSave;
    window.close();
    }
    }
    ....
    <body onLoad="init('<% Response.Write(bSave)%>');">
    .....
    <form id="b" name="b" action="?save=1" method="post"
    target="_self">
    ....

    Any idea ?
    Joel, Nov 25, 2003
    #1
    1. Advertising

  2. I'm team lead on an intranet application that uses lots of modal dialogs,
    and I can tell you that "Submit"s don't work. What you have to do is have a
    script that concantenates all the values together from the form when the
    "submit" button is clicked, assigns that value to a variable and returns it
    before closing the window. The hardest part is coordinating what's sent
    back and forth, and what's processed.

    So, you've got the right idea, with one two many steps. Take a look:
    <form>
    <!-- various input fields here... -->
    <input type=button value="Submit" onClick="submitButton_OnClick">
    <!-- notice: type="button" NOT type="submit" -->
    </form>

    <script language="javascript" type="text/javascript">
    function submitButton_OnClick(){
    // the form is never submitted
    frm = document.forms[0]
    sTemp = 'email=' + frm.email.value
    sTemp += "&fname=" + frm.fname.value
    sTemp += "&lname=" + frm.lname.value
    sTemp += "&open=" + frm.openContact.checked
    returnValue = sTemp
    window.close()
    }

    </script>

    Hope this helps,

    - Wm



    "Joel" <> wrote in message
    news:083701c3b362$bc164990$...
    > Hi there,
    >
    > My original window (A) opens a modal dialog window (B).
    > In B, you fill out a form and submit it to itself for
    > processing. When B reloads, it knows that is successfully
    > processed the form and it suppose to close itself after
    > returning "1" or "0" to A.
    >
    > My problem is that B will never close. When I submit it,
    > it kind of opens a new window and close that one before
    > return to itself (B).
    >
    > Here is a code sample:
    >
    > A
    > ---
    > function newEntry(){
    > var sReturn=window.showModalDialog('b.asp');
    > alert(sReturn);
    > }
    >
    > B
    > ---
    > <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    > <%
    > dim bSave
    >
    > bSave=Request.QueryString("save")
    > if bSave="1" then
    > 'process
    > end if
    > %>
    > ...
    > function init(bSave){
    > if(bSave=='1'){
    > window.returnValue=bSave;
    > window.close();
    > }
    > }
    > ...
    > <body onLoad="init('<% Response.Write(bSave)%>');">
    > ....
    > <form id="b" name="b" action="?save=1" method="post"
    > target="_self">
    > ...
    >
    > Any idea ?
    William Morris, Nov 25, 2003
    #2
    1. Advertising

  3. Joel

    Tim Williams Guest

    Put an iframe in the modal dialog and host the form in that.

    tim


    "Joel" <> wrote in message
    news:083701c3b362$bc164990$...
    > Hi there,
    >
    > My original window (A) opens a modal dialog window (B).
    > In B, you fill out a form and submit it to itself for
    > processing. When B reloads, it knows that is successfully
    > processed the form and it suppose to close itself after
    > returning "1" or "0" to A.
    >
    > My problem is that B will never close. When I submit it,
    > it kind of opens a new window and close that one before
    > return to itself (B).
    >
    > Here is a code sample:
    >
    > A
    > ---
    > function newEntry(){
    > var sReturn=window.showModalDialog('b.asp');
    > alert(sReturn);
    > }
    >
    > B
    > ---
    > <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    > <%
    > dim bSave
    >
    > bSave=Request.QueryString("save")
    > if bSave="1" then
    > 'process
    > end if
    > %>
    > ...
    > function init(bSave){
    > if(bSave=='1'){
    > window.returnValue=bSave;
    > window.close();
    > }
    > }
    > ...
    > <body onLoad="init('<% Response.Write(bSave)%>');">
    > ....
    > <form id="b" name="b" action="?save=1" method="post"
    > target="_self">
    > ...
    >
    > Any idea ?
    Tim Williams, Nov 26, 2003
    #3
  4. Joel

    Joel Guest

    I knew it ! What I've done is that I created an xml tag
    inside of my dialog and a function to fill it with my
    form's fields and I return the xml string to the caller.

    Works fine like this.

    Thank You very much.


    >-----Original Message-----
    >I'm team lead on an intranet application that uses lots

    of modal dialogs,
    >and I can tell you that "Submit"s don't work. What you

    have to do is have a
    >script that concantenates all the values together from

    the form when the
    >"submit" button is clicked, assigns that value to a

    variable and returns it
    >before closing the window. The hardest part is

    coordinating what's sent
    >back and forth, and what's processed.
    >
    >So, you've got the right idea, with one two many steps.

    Take a look:
    ><form>
    > <!-- various input fields here... -->
    > <input type=button value="Submit"

    onClick="submitButton_OnClick">
    > <!-- notice: type="button" NOT type="submit" -->
    ></form>
    >
    ><script language="javascript" type="text/javascript">
    > function submitButton_OnClick(){
    > // the form is never submitted
    > frm = document.forms[0]
    > sTemp = 'email=' + frm.email.value
    > sTemp += "&fname=" + frm.fname.value
    > sTemp += "&lname=" + frm.lname.value
    > sTemp += "&open=" + frm.openContact.checked
    > returnValue = sTemp
    > window.close()
    > }
    >
    ></script>
    >
    >Hope this helps,
    >
    > - Wm
    >
    >
    >
    >"Joel" <> wrote in message
    >news:083701c3b362$bc164990$...
    >> Hi there,
    >>
    >> My original window (A) opens a modal dialog window (B).
    >> In B, you fill out a form and submit it to itself for
    >> processing. When B reloads, it knows that is

    successfully
    >> processed the form and it suppose to close itself after
    >> returning "1" or "0" to A.
    >>
    >> My problem is that B will never close. When I submit

    it,
    >> it kind of opens a new window and close that one before
    >> return to itself (B).
    >>
    >> Here is a code sample:
    >>
    >> A
    >> ---
    >> function newEntry(){
    >> var sReturn=window.showModalDialog('b.asp');
    >> alert(sReturn);
    >> }
    >>
    >> B
    >> ---
    >> <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    >> <%
    >> dim bSave
    >>
    >> bSave=Request.QueryString("save")
    >> if bSave="1" then
    >> 'process
    >> end if
    >> %>
    >> ...
    >> function init(bSave){
    >> if(bSave=='1'){
    >> window.returnValue=bSave;
    >> window.close();
    >> }
    >> }
    >> ...
    >> <body onLoad="init('<% Response.Write(bSave)%>');">
    >> ....
    >> <form id="b" name="b" action="?save=1" method="post"
    >> target="_self">
    >> ...
    >>
    >> Any idea ?

    >
    >
    >.
    >
    Joel, Nov 26, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark
    Replies:
    1
    Views:
    1,662
  2. Ghafran Abbas
    Replies:
    0
    Views:
    4,178
    Ghafran Abbas
    Oct 12, 2004
  3. The Crow
    Replies:
    2
    Views:
    4,347
    Bruce Barker
    Sep 27, 2005
  4. Paul Oakfleet
    Replies:
    1
    Views:
    833
    Chris Riesbeck
    Sep 10, 2003
  5. Jonathan
    Replies:
    0
    Views:
    177
    Jonathan
    Jul 19, 2004
Loading...

Share This Page