Solved

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

Posted on 2006-11-15
4
283 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maven set up 2 143
Java Script nested call 3 86
runtime exception 2 28
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO) 1 15
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
An article on effective troubleshooting
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 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