Solved

displaying employee data in parent window from child window erasing previous data

Posted on 2006-11-15
4
282 Views
Last Modified: 2010-04-01

in the parent jsp i have Multiple Employes button and Show Employees buton;when user clicks Show Employees buton it fetches all employees data from DB and displayed in the below section;that is working fine;if user clicks Multiple Employes button it opens pop window there user can enter specific employee numbers and should be displayed in the parent window wiping out the previous data.in the pop window if user enter invalid employee numbers then  in the popup window itself we should display errors.if user enters correct data then employee details should be displayed in the parent window wiping out the previous data.

i am getting problem while displaying data in parent window when user enter employee no in child window.i am also getting probelm if user enter invalid employee numbers then   we should display errors in the popup window itself;

parent jsp
**********
<html>
    <head>
            <script>
            function popup()
            {
                        var myUrl = 'child.jsp';
                        newWin = window.open(myUrl);
            }



</script>
</head>
<BODY >
<FORM  method="post" action="">

<TABLE width=800 border="1" cellspacing="0" cellpadding="0" bordercolor="#b3b3d9">
  <TBODY>
  <TR bgColor=#ffffff>
    <TD >
   
            <TABLE width="800">
              <TR class="formdata">
          <TD  align=right >
             
                  <INPUT class="input" name='Multiple'  type="button" value='Multiple Employes' onClick = "popup();">
            
              <INPUT class="input" name='button'  type=submit value='Show Employees'>
              </TD>
            </TR>
             
        </TABLE>
        </TBODY>
      <table border="0" width="800" cellpadding="2" cellspacing="1" >
          <tr class='formdata'>
            <td>&nbsp;</td>
          </tr>
        </table>
            <table border="0" width="800" cellpadding="2" cellspacing="1" >
            <tr class='formheader' align=center>
            
                  <td> </td>
            
                  <td >Employee Number</td>
                  <td>EmployeeOrigin</td>
                  <td>EmployeeDest</td>
                  <td  width = "74">Employee Code </td>
            
                  </tr>
            
<tr class='formdata' >

<td><input type="checkbox" id="empCheck0" name="empCheck" ></td>

                  <td>KHY696
                  </td>

                  <td></td>
                  <td>DGDG</td>
                  <td>DGDG</td>
                  <td></td>
                  <td></td>
                  <td></td>
                  
            </tr>
           
<tr class='formdata' >

<td><input type="checkbox" id="empCheck1" name="empCheck"></td>

                  <td>KHY697
                  </td>
                  <td></td>
                  <td>FHFH</td>
                  <td>FHFH</td>
                  <td>KG</td>
                  
            </tr>
           

         </FORM>

   
    </body>
</html>






child.jsp
*********
 
<html>
<head>
<script>
function sendData()
{

      Url = "main.jsp";
      document.forms[0].action = Url;
      document.form1.submit();

}
 

 

</SCRIPT>
</head>
<BODY>
<form name="form1" method="post" action="" >

      <table width="800" border="1" cellspacing="0" cellpadding="0" bordercolor="#b3b3d9">
      <tr>
            <td class=formheader>
                  <table width="800" border="0" cellspacing="1" cellpadding="2">
                  <tr>
                        <td class=formlabel colspan="2">Enter Multiple Employees  for deletion</td>
                  </tr>
                  </table>
                  <table  class='formlabel' border="0" cellspacing="0" cellpadding="0" width=100%>
                  <tr>
                        <td class=formdata colspan="2">
                              <font color="red" size="2"><b>

                              </b></font>
                        </td>
                  </tr>
              </table>
                  
                  <table width="800" border="0" cellspacing="1" cellpadding="2">
                  <tr>
                  <td class=formheader align=center>Emp No<input type="text" name="empno1" value=""></td></tr>
                  <tr><td class=formheader align=center>Emp No<input type="text" name="empno2" value=""></td></tr>

                  </table>
                  <table width="800" border="0" cellspacing="1" cellpadding="2">
                        <tr class=formdata>
                        <td class=formdata align = 'right'><input type="button" value="ENTER" name="ENTER"  class='input' id="ENTER" onClick="sendData();"></td>
                        
                        </tr>
                  </table>
  </table>
</form>
</body>
</html>
0
Comment
Question by:chaitu chaitu
  • 3
4 Comments
 
LVL 5

Expert Comment

by:deeppra
ID: 17954443
send me where u have the problem
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 17954499
i am not able to hide the parent data when i entered employee number in child window.
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17954626
// open a document called 'thisdoc.html'
// in a window named 'win02'
window.open('thisdoc.html', 'win02');

//to close the window
win02.close();

0
 
LVL 5

Accepted Solution

by:
deeppra earned 500 total points
ID: 17954763
in the parent window dont put every thing in a single table. split the table into two in the first table you have all the buttons and below that u have a div element like this

<div id="result">
.....
</div>

during the first time the content of the div should be empty and after the user clicks show employees button a javascript should be triggered then it should send the request to the server and when the server sends back the response the content is updated in the div element like this

//After getting the response from the server store the details in the variable say 'res'
//then update the div tag with this command
window.document.getElementById('result').innerHTML = res;

when u r accessing from the child window then use
window.parent.document.getElementById('result').innerHTML = newres;

so that the parent window will be updated with the new content available in newres variable

For accessing parent element refer this document
http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_window.asp

For Sending the request to the server u can use AJAX u can find many materials in the net
check this link u have the code for calling a servlet
http://www.thescripts.com/forum/thread169178.html

for details about AJAX see http://www.activemq.org/site/ajax.html

I think this is useful

Thanks
Pradeep D
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java.lang.UnsupportedClassVersionError 8 374
Javascript onclick event 4 107
Fisheye tool 2 104
Getting NoSuchMethodError on accessing a spring mvc project 3 158
There are many Password Managers (PM) out there to choose from. PM's can help with your password habits and routines, but they should not be a crutch you rely on too heavily. I also have an article for company/enterprise PM's.
With the rapid rise in mobile usage, mobile devices are here to stay and have become an integral part of doing business. Here are 9 great apps for your BYOD environment.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now