Closed Thread Icon

Topic awaiting preservation: how to parse parameter from child windows to parent in JSP (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=24088" title="Pages that link to Topic awaiting preservation: how to parse parameter from child windows to parent in JSP (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: how to parse parameter from child windows to parent in JSP <span class="small">(Page 1 of 1)</span>\

 
Pimms One
Bipolar (III) Inmate

From: Australia
Insane since: Jun 2003

posted posted 11-18-2004 04:23

I have two JSP i.e. course1.jsp and course2.jsp. I would want to find out how I could parse the parameter/value from child window to the parent window when the child window get closed.

What I am trying to do is actually a file upload process. The child windows will open for user to upload the file, and when close, the file name will be parse into the parent form for database update. Is this something possible at all? or is there any other better approaches.

Thank you.

These are the two files:

--------course1.jsp ------------

Attach File <p>
<FORM name="courseForm" action="course2.jsp" method="post" enctype="multipart/form-data">
<TABLE cellSpacing=1 cellPadding=3 border=0 WIDTH=500>
<TR >
<TD>
<input type="text" NAME="f_file_name" size="30" VALUE="this value should be taken from child windows">
<a href="course2.jsp" target="new"> get file name </a>
<p>
<INPUT class="buttons" TYPE="submit" NAME="submit" VALUE="Submit">
</TD>
</TR>
</TABLE>
</FORM>

---- course2.jsp -------

<%
String filename = "this is the string needs to go back to parent windows when I click on close";
%>
<p>
<a href="#" onClick=window.close();> close </a>

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 11-18-2004 06:48

Alright I'm not entirely sure what you are trying to do. But this isn't really something for JSP so much as Javascript. Unless you want to refresh the parent window, but that would kind of (usually) defeat the purpose of the child window.

The way to do this in Javascript is like so:


---- course2.jsp -------

<%
String filename = "this is the string needs to go back to parent windows when I click on close";
%>
<head>
<script language="javascript">

var file = "<%= filename &>"; // Becareful to escape double quotes if necessary

function updateParent() {
window.opener.forms.courseForm.f_file_name.value = file;
window.close();
}
</script>
</head>
<p>
<a href="#" onClick="updateParent()"> close </a>




.:[ Never resist a perfect moment ]:.

(Edited by bitdamaged on 11-18-2004 06:50)

Pimms One
Bipolar (III) Inmate

From: Australia
Insane since: Jun 2003

posted posted 11-25-2004 00:04

I changed window.opener.forms.courseForm.f_file_name.value = file; to

window.opener.courseForm.f_file_name.value= file and it works.

Thank you.

« BackwardsOnwards »

Show Forum Drop Down Menu