O
Olan Wilson
I have a pretty standard ASP page I want to display in a modal dialog box.
The first part of the script is a couple input boxes and a submit button
inside of a form with its action property set to the same ASP page and a
method of post. The second part is the form handler that inserts the data
entered by the user into a database table. The initial HTML form displays
just fine in the modal dialog box, but when the user clicks the submit
button a new window is opened that the ASP code executes in and then closes
with a window.close command. I would like for the form processing to occur
in the same modal dialog box and then have that same dialog either close or
display the error as appropiate. Any ideas?
My guess is that I need to specify a target for the form, but I can't figure
out what target to use.
From memory the code is something like:
AddNew.asp:
select case request.querystring("action")
case "addnew"
<form name=AddNew method=post action="AddNew.asp?action=save">
<input type=text name=txtHostName>
<input type=text name=txtDesc>
<input type=submit name=subAdd value=Add>
</form>
case "save"
'insert the data in the database
if err.number = 0 then
response.write ("<script
language=""vbscript"">window.close</script>")
else
response.write ("error stuff")
end if
end select
This page is called from another page like so:
QueryLists.asp:
'populate the page from the database
..
..
..
<input type=button name=btnAdd value="Add New">
..
..
..
<script language="vbscript">
function btnAdd_OnClick
window.showmodaldialog "AddNew.asp?action=addnew"
document.location.reload ("QueryLists.asp")
end function
</script>
The first part of the script is a couple input boxes and a submit button
inside of a form with its action property set to the same ASP page and a
method of post. The second part is the form handler that inserts the data
entered by the user into a database table. The initial HTML form displays
just fine in the modal dialog box, but when the user clicks the submit
button a new window is opened that the ASP code executes in and then closes
with a window.close command. I would like for the form processing to occur
in the same modal dialog box and then have that same dialog either close or
display the error as appropiate. Any ideas?
My guess is that I need to specify a target for the form, but I can't figure
out what target to use.
From memory the code is something like:
AddNew.asp:
select case request.querystring("action")
case "addnew"
<form name=AddNew method=post action="AddNew.asp?action=save">
<input type=text name=txtHostName>
<input type=text name=txtDesc>
<input type=submit name=subAdd value=Add>
</form>
case "save"
'insert the data in the database
if err.number = 0 then
response.write ("<script
language=""vbscript"">window.close</script>")
else
response.write ("error stuff")
end if
end select
This page is called from another page like so:
QueryLists.asp:
'populate the page from the database
..
..
..
<input type=button name=btnAdd value="Add New">
..
..
..
<script language="vbscript">
function btnAdd_OnClick
window.showmodaldialog "AddNew.asp?action=addnew"
document.location.reload ("QueryLists.asp")
end function
</script>