showModalDialog and submit

J

Joel

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 ?
 
W

William Morris

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
 
J

Joel

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 said:
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 ?


.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top