Wednesday, 4 September 2013

Get value from popup page Javascript

sample1.html:
 
<html>
<head>
    <title>Sample 1</title>
</head>
<body>
<script language="JavaScript">
    function windowOpen() {
        var myWindow=window.open('sample2.html','windowRef','width=200,height=200');
       if (!myWindow.opener) myWindow.opener = self;
    }
</script>
<form name="frmMain" method="post" action="">
    <input type="text" value="" name="txtVol" id="txtVol">
    <input name="openPopup" type="button" id="openPopup" onClick="Javascript:windowOpen();" value="Get Value">
</form>
</body>
</html>
 
 
sample2.html:
 
<html>
<head>
   <title>Sample 2</title>
</head>
<body>
<script language="JavaScript">
    function updateOpener() {
        window.opener.document.frmMain.txtVol.value = document.frmMain.txtInput.value;
        window.close();
    }
</script>
Value :<form name="frmMain" method="post" action="">
    <input type="text" name="txtInput" value="">    
     <input name="Close" type="submit" id="Close"onClick="Javascript:updateOpener()" value="Close">
</form>
</body>
</html>

No comments:

Post a Comment