0

enter image description here

I have 3 buttons.

  1. search button : this will open popup page.
  2. add row button : this will trigger a javascript function to add row.
  3. select button : will trigger a javascript function to get row value and send it to main page.

search and add row buttons are in main page, and select button is on popup page.

i need select button to handle javascript function in main page, so i can remove add row button.

to put it simple, my question is how i do trigger javascript function to add row in main page, using select button in popup page?

if my question isn't clear please ask, thanks.

Mehul Tandale
  • 331
  • 1
  • 5
  • 17
stacheldraht27
  • 392
  • 1
  • 6
  • 26

2 Answers2

0

I would take a general example.

(parent window)

<html> 
<script language="javascript"> 
function openWindow() { 
  window.open("target.html","_blank","height=200,width=400, status=yes,toolbar=no,menubar=no,location=no"); 
} 
</script> 
<body> 
<form name=frm> 
<input id=text1 type=text> 
<input type=button onclick="javascript:openWindow()" value="Open window.."> 
</form> 
</body> 
</html>

(child window)

<html> 
<script language="javascript"> 
function changeParent() { 
  window.opener.document.getElementById('text1').value="Value changed..";
  window.close();
} 
</script> 
<body> 
<form> 
<input type=button onclick="javascript:changeParent()" value="Change opener's textbox's value.."> 
</form> 
</body> 
</html>

http://www.codehappiness.com/post/access-parent-window-from-child-window-or-access-child-window-from-parent-window-using-javascript.aspx

More discussion: javascript - pass selected value from popup window to parent window input box

Community
  • 1
  • 1
Sanjay Verma
  • 1,390
  • 22
  • 40
  • in my picture on above, i already able to send value to parent window. what i want is how to run javascript function in parent window from child window ^^ – stacheldraht27 Oct 10 '15 at 06:07
0

Alhamdulillah finaly i got the answer to execute javascript function on parent window from popup window^^,

on parent window:

<html>
<head><title>MAIN WINDOW</title></head>
<body>
   <script type="text/javascript">
   function hello(){
   alert("Hello");
   }
   </script>
</body>
</html>

and on popup window:

 <html>
    <head><title>POPUP WINDOW</title></head>
    <body>
    <input type="button" onClick="javascript:callHelloOnParent()">
    <script type="text/javascript">
    function callHelloOnParent(){
      window.opener.hello();
      return false;
    }
    </script>
  </body>
    </html>
stacheldraht27
  • 392
  • 1
  • 6
  • 26