Forum Moderators: open
pop up window submit form javascript
Hi, I just launched in my site an addin, it is basically a order product button in a pop up picture window of the item.
So the customers can order the item from the pop up Picture window if dessired... the complicated thing for me is how to do this:
- To close that pop window after click the order button.
those are my first 2 attemps with no satisfactory results...
This first code closes the window and post nothing.
<form name="cart" method="post" action="scriptname.cgi">
<a href="javascript:document.cart.submit();" onClick="javascript:self.close();">Submit</a>
</form>
This 2nd code submit the thing but dont close the window.
<form onsubmit="javascript:self.close();" method=post action="scriptname.cgi">
<a href="javascript:document.cart.submit();" onsubmit="javascript:self.close();">Submit</a>
</form>
any idea with that mission?
thanks in advance.
self.close() will probably be executed before the form has submitted. As I see it, there are two possibilities:
1) submit using the window opener as the target, which makes calling self.close the way tedster suggests completely safe
2) submit and return some HTML which then closes the window
this is the ie code:
<form method=post action="http://order.store.domain.net/cgi-bin/wg-order?yhst-1638995+6731-wt" onsubmit="javascript:window.opener.cart.submit();self.close();return false;">
<input name=vwcatalog type=hidden value=yhst-16395725>
Qty: <input name=vwquantity value=1 maxlength=5 size=2>
<input type=submit value="Order">
<input type=hidden name=.autodone value="http://mysite.com/6731-wt.html">
</form>
any idea?
thanks!