this might be the easiest problem to solve but I have searched through the internet with no luck.
I have a Parent Window which creates a popup which retrieves possible addresses based on a partial postcode. This is all working and now I just need to pass the values back to the parent window.
This again I have been able to do, the problem I have is that there are multiple forms on the parent page with the same field names…. i.e the form name is unique (FormAddress1, FormAddress2 etc) but the fields are the Same (House No, Address1,Region,zipcode etc).
The current JS I am using in my link to call the main function is;
<a href="javascript:js_PushPostcode('FormAddress1','trValue1','strValue2')">Use this address</a>
The Function passing these values to parent page as follows;
<script type="text/javascript">
function js_PushPostcode(jsAddressForm,jsAddress1,jsAddress3){
void(window.opener.document.FormAddress1.Address1.value = jsAddress1);
void(window.opener.document.FormAddress1.Address1.value = jsAddress3);
}
</script>
I would really like to replace the static form name (FormAddress1 in the case above with the variable jsAddressForm.
Please help…. My knowledge of JavaScript is limited as you can probably tell.
Thanks for any help you can provide.
Dan
You can use the name of the form name in the DOM in the fallowing way:
I’m not sure it’s 100% cross browser, but it should be. Test it.