Thursday, March 13, 2014

Pass Value from child popup window to parent window at onclick event

1. Parent  Window Code

<form:input path="companyId" id="companyInput" size = "30"/> &nbsp;<input type="button" onclick="popup()" value="Lookup"/></td>

<script>
function popup(){
     window.open('../company/companySearch.html','Company Search','width=600,height=600,resizable=1,scrollbars=yes,top=100,left=100');

}</script>

2. Child Popup Window Code:

Here On click on a link the link value will be returned back to text box in parent window

<a id="compId" href="" onclick ="sendValue(${comp.companyId})"><c:out value="${comp.companyId} "/></a>

<script>
function sendValue(compId){
    window.opener.document.getElementById('companyInput').value=compId;
    window.close();
 }
</script>