with help from :http://www.aspsnippets.com/Articles/Pass-value-from-child-popup-window-to-parent-page-window-using-JavaScript.aspx
I am trying to pass a value from a child popup window to parent window.
my button has two functions 1 to save the variable and 2 to Pass the variable to parent form.
The popup window is not closing,and not passing the value.
My Code is as below.
Parent form:
<script type="text/javascript">
var popup;
function InsertSig() {
popup = window.open("Signature.aspx", "Popup", "width=600,height=300");
popup.focus();
}
</script>
<asp:Image ID="ClientSig" runat="server" />
<input type="button" value="Insert Signature" onclick="InsertSig()" /></td>
Child Form:
the first function:
saveButton.addEventListener("click", function (event) {
if (signaturePad.isEmpty()) {
alert("Please provide signature first.");
} else {
var signatureData = signaturePad.toDataURL();
$('#signature-data').val(signatureData);
}
return false;
});
the second function:
<script type="text/javascript">
function InsertSig() {
if (window.opener != null && !window.opener.closed) {
var ClientSig = window.opener.document.getElementById("ClientSig");
ClientSig.Src = document.getElementById("#signature-data").value;
}
window.close();
}
</script>
lastly the button:
<a class="button save" data-action="save;InsertSig();" href="#">Save</a>