Click to See Complete Forum and Search --> : Get data from popup window


charles_cp
05-11-2005, 10:27 AM
Dear All,

I would like to get data from a popup window. I had design the following code. When I run test.asp and click the button, the popup window will show and the user can input data in the input box. After that, the user click the button in popup window. The test.asp will show the data.
The problem is I cannot show the data without the input box in test.asp. Can save the data to Session("aaa") in popup window? Then, I can use Response.write Session("aaa") to show the data without the input box.


test.asp


<SCRIPT LANGUAGE="JavaScript">
function ShowPopup(oDoc)
{
window.open("test2.asp?backf="+oDoc,"window", "height=210, width=300, resizeable=no,","");
}
</script>


<p>Please click the button to add the text:</p>
<form method="POST" name="HICSF">
<input id="VonDatum" type="text" name="txtDate" size="20" >
<input type="button" value="Click me to add" onClick="javascript:ShowPopup('HICSF.VonDatum')"></form>






test2.asp


<%
RecObj = Request.QueryString("backf")
Response.Write "<Script language='javascript'> "
Response.Write "var l_SelDate; "
Response.Write "function PutDate() "
Response.Write "{ "
Response.Write "window.opener." & RecObj & ".value = document.test2.T1.value; "
Response.Write "window.close(); "
Response.Write "} "

Response.Write "</Script> "
%>
<Script language="javascript">

window.moveTo((window.screen.width - 300),(window.screen.height - 125)/2);
</Script>


<form method="POST" action="" name="test2">
<p><input type="text" name="T1" size="20"></p>
<p><input type="submit" value="Submit" name="B2" onClick="javascript:PutDate();"></p>
</form>








Thank you very much!
Charles

wmif
05-11-2005, 08:27 PM
you could have the popup window post to a page in this window (even the same page), have it process the data into your database and then have a third "page" return a javascript function that tells it "window.opener.location = " the page that displays your data. use a query string variable to tells the main page the id of the information that you want to show.

phpnovice
05-12-2005, 09:25 AM
I would like to get data from a popup window. I had design the following code. When I run test.asp and click the button, the popup window will show and the user can input data in the input box. After that, the user click the button in popup window. The test.asp will show the data.
The problem is I cannot show the data without the input box in test.asp.
You really need to use a POST back to the main window -- however, this requires that JavaScript be enabled so that the main window can name itself:

test.asp:
<body onload="window.name='mainWindow'; return true;">
Then, the popup window can POST the form data back to the main window, as follows, and your ASP code there can place the data into the page using normal HTML -- no FORM fields required to display that data:

test2.asp:
<form name="test2" method="POST" target="mainWindow" action="test.asp">

aronius_maximus
05-31-2005, 06:07 AM
hi all,

i have tried to use the code which has been provided by charls_cp....i modified it a bit to integrate it in my project but i am not getting the value back in the main form...i have tried everything but the thing simply refuses to work....can any of u please help me......i need the solution very badly.

the code from two files is as under

test.asp

<SCRIPT LANGUAGE="JavaScript">
function ShowPopup(oDoc)
{
window.open("test2.asp?backf="+oDoc,"window", "height=300, width=300,","");
}
</script>


<p>Please click the button to add the text:</p>
<form method="POST" name="HICSF">
<input id="VonDatum" type="text" name="txtDate" size="20" >
<input type="button" value="Click me to add" onClick="javascript:ShowPopup('HICSF.VonDatum')"></form>

test2.asp

<%
RecObj = Request.QueryString("backf")
Response.Write "<Script language='javascript'> "
Response.Write "var l_SelDate; "
Response.Write "function PutDate() "
Response.Write "{ "
Response.Write "window.opener." & RecObj & ".value = document.test2.ct_cd.value; "
Response.Write "window.close(); "
Response.Write "} "

Response.Write "</Script> "
%>
<Script language="javascript">

window.moveTo((window.screen.width - 300),(window.screen.height - 125)/2);
</Script>


<form method="POST" action="" name="test2">
<%
Set objConn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.recordset")
objConn.Open "DRIVER={Microsoft ODBC for Oracle};SERVER=******;UID=******;PWD=*****;"

Q=" SELECT * FROM LEGAL_COURTCODE"
RS.Open Q, objconn, 2,3,1
%>
<TABLE>
<TR><TD width=120 align=LEFT><FONT COLOR=#FF030A><b><u>COURT CODE</U></B></TD>
<TD width=300 align=LEFT><FONT COLOR=#FF030A><b><u>COURT NAME</U></B></TD>
<TD width=300 align=LEFT><FONT COLOR=#FF030A><b><u>COURT TYPE</U></B></TD>
</TR>
</TABLE>
<%
DO WHILE NOT RS.EOF
%>
<TABLE>
<TR>
<td><input type=radio name=stn value=<%=rs.Fields("COURT_code")%> ondblclick=a()>
<TD width=120 align=LEFT bgcolor="#e1f8ff"><input name=ct_cd value=<%=RS.Fields("COURT_CODE")%>></TD>
<TD width=300 align=LEFT bgcolor="#e1f8ff"><FONT COLOR=#FF030A><%=RS.Fields("COURT_NAME")%></TD>
<TD width=300 align=LEFT bgcolor="#e1f8ff"><FONT COLOR=#FF030A><%=RS.Fields("C_TYPE")%></TD>
<td></td></TR>
<%
RS.MoveNext
LOOP%>
<tr><td>
<p><input type="submit" value="Submit" name="B2" onClick="javascript:PutDate();"></p></td></tr>
</form>

to my knowledge i have done evry thing correctly.....but please tell me if i have missed somthing :confused: