Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 291
  • Last Modified:

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


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
chaitu chaitu
Asked:
chaitu chaitu
  • 3
1 Solution
 
deeppraCommented:
send me where u have the problem
0
 
chaitu chaituAuthor Commented:
i am not able to hide the parent data when i entered employee number in child window.
0
 
deeppraCommented:
// open a document called 'thisdoc.html'
// in a window named 'win02'
window.open('thisdoc.html', 'win02');

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

0
 
deeppraCommented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now