Thursday, 26 March 2015

How to post a form (from parent window) to window popup (child window)

I was just trying to open a new window popup and condition was to send parametes to the child window (popup having some fixed width and height) by posting a form.

While searching on google, I found few suggestions like -
put target="_blank" in form but this will open a new tab

Finally, I have written following code which serves the purpose.

Below code is submitting form to popup window "Details" after clicking on link.

show_details() is function which is opening windwo with same name that we have specified form attribute "target" i.e. "details_popup" which has fixed height and width as per our requirement.

Code :


<a name="submit_form_link" href="javascript:show_details()">
<form name="frmTempSearchResult" id="frmTempSearchResult" action="Details.cfm#" method="post" target="details_popup">
                <input type="hidden" name="frmId" value="">
                <input type="hidden" name="frmUsername" value="ds">
                <input type="hidden" name="frmPassword" value="ds">
</form>

<script type="text/javascript">
                function show_details()
                {                                             
                                window.open('', 'details_popup', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=1100, height=700, top='+((screen.width/2)-(1000/2))+', left='+((screen.height/2)-(900/2)));
                                document.frmTempSearchResult.submit();
                }
</script>

2 comments:

  1. Excellent blog! Thank you for posting this informative blog. Here is a piece of good information regarding Web Development. Keep more sharing.

    ReplyDelete
  2. Thank you for very informative article Thanks Buddy

    If you are looking for web development services, look no further. Branches Marketing Solutions are a top-rated website development company. We offer custom web development services that meet your goals & budget. Contact us for more info.

    ReplyDelete