PDA

View Full Version : Pass Data from Parent to Pop Up window



forums.fanatic
11-05-2009, 07:17 AM
Hey Friends,

Reached this forum while searching for a solution thro Google. Saw a thread that discussed the solution, but still could not find a solution

I have two files named empproject.jsp and empnames.jsp..I want to pass the name entered in the EMPLOYEE NAME field in empprojects to a field in empnames and from there i would want to query using that name to retrieve the full name of the employee. Or if you could suggest me a better way to do this..you are most welcome....

empprojects.jsp



<link rel="STYLESHEET" type="text/css" href="calendar.css">
<script language="JavaScript" src="cal_empprj.js" type="text/javascript"></script>
</head>
<body bgcolor=black>
<form id="empprojects" method=post>
<center>

<table border="0">
<tbody>

<tr>
<td><font color=white>Project Short Name</font></td>
<td><input type="text" name="prj_shrt_name" value="" /></td>
</tr>

<tr>

<td><br><font color=white>Project Name</font></td>
<td><br><input type="text" name="prj_name" value="" /></td>
</tr>

<tr>
<td><br><font color=white>Project Description</font></td>
<td><br><input type="text" name="prj_desc" value="" /></td>
</tr>

<tr>
<td><br><font color="white">Client Name</font></td>
<td><br>
<select name="client_name">
<option>-Select Client-</option>
<%
rs = stmt.executeQuery("select clientname,clientgrp from clientdetails");
while (rs.next()) {
%>

<option value = "<%=rs.getString("clientname")%>"> <%=rs.getString("clientname")%>(<%=rs.getString("clientgrp")%>)</option>
<%}%></select></td>

</tr>

<tr>
<td><br><font color=white>Employee Name</font></td>
<td><br><input type="text" name="empname" value="" /></td><td><br><input type="button" value="Fetch" name="fetch" onClick="window.open('empnames.jsp','Select Employee','width=400,height=200')"/></td>
</tr>
<tr>
<td><br><font color=white>Project St. Date</font></td>
<td><br><input type="text" name="st_dt" value="" /></td>
<td><br><a href="javascript: void(0);" onmouseover="if (timeoutId) clearTimeout(timeoutId);window.status='Show Calendar';return true;" onmouseout="if (timeoutDelay) calendarTimeout();window.status='';" onclick="g_Calendar.show(event,'empprojects.st_dt',true,'yyyy-mm-dd'); return false;"><img src="calendar.gif" name="imgCalendar" width="34" height="21" border="0" alt=""></a></td>
<td width="100"></td>
</tr>
<tr>
<td><br><font color=white>Project End Date</font></td>
<td><br><input type="text" name="end_dt" value="" /></td>
<td><br><a href="javascript: void(0);" onmouseover="if (timeoutId) clearTimeout(timeoutId);window.status='Show Calendar';return true;" onmouseout="if (timeoutDelay) calendarTimeout();window.status='';" onclick="g_Calendar.show(event,'empprojects.end_dt',true,'yyyy-mm-dd'); return false;"><img src="calendar.gif" name="imgCalendar" width="34" height="21" border="0" alt=""></a></td>
<td width="100"></td>
</tr>
<tr>
<td><br><font color=white>Supervisor Name</font></td>
<td><br><input type="text" name="supervisor" value="" /></td>
</tr>
<tr>
<td><br><font color=white>Supervisor E-mail</font></td>
<td><br><input type="text" name="super_email" value="" /></td>
</tr>
<tr>
<td><br><font color=white>Alternate Supervisor</font></td>
<td><br><input type="text" name="alt_super" value="" /></td>
</tr>
<tr>
<td<br><font color=white>Alternate Supervisor E-mail</font></td>
<td><br><input type="text" name="alt_email" value="" /></td>
</tr>
<tr>
<td<br></td>
<td><br><input type="submit" value="Add Project" name="submit" /></td>
</tr>
</tbody>
</table>

</center>
</form>


This is the POP up window Code empnames.jsp



<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Select Employee</title>
<script language="JavaScript">
window.onload() = function(){
var pw = window.opener;
if(pw){
var empproj = pw.document.forms['empprojects'];
var popupwindow = document.forms['popup'];

popupwindow.elements['empname'].value = empproj.elements['empnamefromparent'].value;

}
}
</script>
</head>
<body>

<form name="popup">
<table border="0">
<tbody>
<tr><td><input type="text" name="empnamefromparent" value="" /></td></tr>
<tr>

<td>
<%rs=stmt.executeQuery("select fname,mname,lname from empdetails where fname='"+request.getParameter("empnamefromparent")+"'");%>
<%while (rs.next()){%>
<input type="radio" name="emp" value="" /><%=rs.getString("fname")%><%=rs.getString("lname")%>
<%}%></td>

</tr>
</tbody>
</table>
</form>


Any solution is highly appreciated..

THANKS AND REGARDS
FF