Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to open a modal window with form and submit it to itself

Status
Not open for further replies.

Kingkumar

Programmer
Jan 21, 2003
167
0
0
US
Hi,
I need help to do the following as i dont know how to go about it
1. on button click open a modal window
2. modal window has a form with drop down which shoudl have data as what selected in the listbox (multiselect) in the main form
3. when the data is selected in themodal window and submit button is clicked it should display whether the database was updated ( with message update complete) or not ( with message update incomplete)
4. should have a button to close the window

any help in how to go about it or code snippet would greatly be appreciated.

Thanks.



 
I am a little confused to your question. You can open a modal window using javascript (window.open, I believe) and then refer back to the original page using .opener. But parts 2 and 3 are somewhat confusing (or maybe I'm not over my weekend just yet). You can pass values to the modal window (using querystring is one way). But then, are you trying to update a database (server-side?) and then pass a value back to the calling page or what? Could you be a little more specific as to what you are attempting to do? Also, if this is all being done client-side (presumably with javascript), you may want to also do some searching for this in forum216. Some searches within this forum may also be useful since the outline of your question is one that has been asked many times here.

------------------------------------------------------------------------------------------------------------------------
"I am not young enough to know everything."
Oscar Wilde (1854-1900)
 
hi chopstik,
Thanks for your reply
i did the searching part but couldnt find anything helpful to my situation ( though a lot of stuff on modal windows)

ONe of the thigns i understood was u cnat post back to the modal window ???(dotn know whether i am right or wrong)


what i need is that when the user is in the modal windwo he does select some options from list boxes in the modal window and based on this selection when the submit button is clicked in the modal window the data base is upsated and the same modal window should be again displayed with the message whether the update was sucess or failure.
nothing to do with main window in this step.


please let me know if i am not clear in putting down my thoughts
thanks
 
I am unaware of any problems with trying to post to a modal page. I have done it within one of my own applications when using them for search functionality to retrieve requested records to the same modal page. You simply submit your form to the next page (within the modal window), do your normal processing and then run from there. If you have a more specific question, you can post some of the relevant code and we can try to help you from there.

------------------------------------------------------------------------------------------------------------------------
"I am not young enough to know everything."
Oscar Wilde (1854-1900)
 
The problem i am facing is that when i submit the modal form to itself it opens another modal window with the old modal window still existing
here is my code


<%@ Language=VBScript %>
<%
Option Explicit
on error resume next
Response.Buffer = true
Response.Expires = -1
dim strMarket, conn, strProc, objWebData, rs, strGroup
conn = Application("hope")
set objWebData = server.CreateObject("WebData.Reader")
set rs = server.CreateObject("ADODB.recordset")
'set rs = objWebData.getRS(cstr(conn),strProc,1)

if Request.Form("SelAgent")<>"" then
strMarket = Request.Form("SelAgent")
end if
if Request.QueryString("SelAgent") <> "" then
strMarket = Request.QueryString("SelAgent")
end if

%>

<HTML>
<HEAD>
<link rel="stylesheet" type="text/css" href="/css/mpstyle2.css">
<title>Proxy User Details</title>
</HEAD>
<BODY>
<!--#include virtual="/include/banner.asp"-->
<table cellspacing="0" cellpadding="2" border="0" height="100%" valign="top">
<tr>
<td style="background-color: #92CCC3; width: 160px;" valign="top">
<!--#include virtual="/include/menu.asp"-->
</td>
<td valign="top" width="100%">
<form name=frmProxyAgent id=frmProxyAgent method=post action="ProxyDetails.asp">
<br>
<div class="Lvl1Indent" style="width=450px;height=40px;">
<table width=440>
<tr>
<td width=120>
<b>Choose an Agent</b>
</td>
<td>
<%
dim strParam
strParam = Request.QueryString("list")
if strParam <>"" then
strProc = "spUSER_GetUserAgents '" & strParam & "'"
set rs = objWebData.getRS(cstr(conn),strProc,1)
Response.Write "<select name=selAgtAddList id=selAgtList style=width:200px onchange=frmProxyAgent.submit()>"
While not rs.EOF
Response.Write "<option "
Response.Write "value=" & rs.Fields("AgentNo")
Response.Write ">" & rs.Fields("AgentName") & "</option>"
rs.MoveNext
Wend
Response.Write "</select>"
Response.Write ("<BR>")
end if
set rs = nothing
%>
</td>
</tr>
</table>
</div>
<BR>
</form>

<%set objWebData = nothing
set rs = nothing%>

</BODY>
</HTML>
 
I don't see anything in your code that would cause it to open a new modal window. The form should simply submit to itself within the same window. Not sure why it is opening a second modal window...

Just out of curiosity, what is the name of this page? Is this page posting to itself (in other words, is this the "ProxyDetails.asp" page)?

------------------------------------------------------------------------------------------------------------------------
"I am not young enough to know everything."
Oscar Wilde (1854-1900)
 
hey chopstik,
i forgot to mention proxydetails.asp itslef is opened using javascript function and window.showModalDialog
I dont know if that makes a difference???
let me know if you think that might be the reason or if u see something in the code.
thanks for your help
--king
 
Try to call the page directly on your browser, eg. and do a submission. See if it opens another window.

Also, you can try to add ' target="_self" ' in the form tag, as such:
<form name=frmProxyAgent id=frmProxyAgent method=post action="ProxyDetails.asp" target="_self">

Hope this helps.

Allan
 
Hi Allan,
i cant open it directly in the browser because the dropdown gets populated by one of the values passed from the previous page.

Also tried targer ="_self" but it still opening a new window
going nuts as cant find naything in the code which might cause it to open a new window:(

any other suggestions

--king
 
If you're passing a value through the querystring, then just add that to the URL when testing it directly on the browser as avu suggested.
Also, is the code you've posted above the complete code for this modal page? If not, could you please post all of it? Additionally, what is the code in the original page that calls the modal window?

------------------------------------------------------------------------------------------------------------------------
"I am not young enough to know everything."
Oscar Wilde (1854-1900)
 
Ok then, I next suspect the line "onchange=frmProxyAgent.submit()" is doing something 'funny'.

Can you try remove this & use a Submit button instead (just to test out)?
Or (if you haven't already...) try "onchange=document.frmProxyAgent.submit()",
Or "onchange=document.frmProxyAgent.submit(); return true;"

Other than this, I can't see anything out of ordinary in your script.

Also, it looks like you pass parameters to this modal window using QueryString. I'm sure you can call this page directly with all appropriate parameters, eg.

Allan
 
OK Guys i am on the verge of brakedown now :)

here is the code for calling the modal window

function GetProxy()
{
strRmvAgtLst = setForm(document.frmAssignRec.selAgtRmvList)
//alert(strRmvAgtLst)
var strUrl = "CopyOfProxyDetails.asp?list="
strUrl = strUrl + strRmvAgtLst
if (strRmvAgtLst.length > 0) {
window.showModalDialog(strUrl,"" , "dialogHeight:550px;dialogWidth:700px;center:yes;help:no;resizable:yes;status:no")
}
}

allan i have tried all the above methods u told.
1. when i directly open it in the browser it doesnot open a new window but as soon as i do it using modal window it starts opening a new window.
2. i used a function onchange and also tried using a submit button the no change


any suggestions???

frustated
--king
 
onchange i call a function fncTransfer


the code for function is as follows

function fncTransfer()
{
//alert("test");
document.frmProxyAgent.submit()
return true;
}
but still opens a new window
 
Kingkumar, for future reference, if you are working with ASP.NET, the proper forum for your question is forum855. That would explain why we could not find the problem in this forum. ;-)

------------------------------------------------------------------------------------------------------------------------
"I am not young enough to know everything."
Oscar Wilde (1854-1900)
 
chopstik i am not working with asp.net i am working with classic asp but the concept remains the same thats why i referred to it.
and following one of the methods there my modal window is no more opening any windows
thanks for your help though it was very nice of you.
 
Ah, well, in that case, I stand corrected. My apologies for the misunderstanding and thanks for the tip! [thumbsup]

Glad that you were able to find the answer!

------------------------------------------------------------------------------------------------------------------------
"I am not young enough to know everything."
Oscar Wilde (1854-1900)
 
Good find king. Glad to know your problem is now solved.

We learn something new everyday!! :)

Cheers,

Allan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top