admin管理员组文章数量:1289857
I want to have a form and need to submit it to a url in a new pop up window on button onclick action. I want something like this.
<form id = "test" name = "test" action = "preview.jsp">
Email : <input type = "text" name = "email"/>
<button id = "submitButton" onclick = "submitFormInPopUp()"/>
</form>
So how to write this function submitFormInPopUp() which posts to action url in a new pop up page.
Thanks
Jitendra
I want to have a form and need to submit it to a url in a new pop up window on button onclick action. I want something like this.
<form id = "test" name = "test" action = "preview.jsp">
Email : <input type = "text" name = "email"/>
<button id = "submitButton" onclick = "submitFormInPopUp()"/>
</form>
So how to write this function submitFormInPopUp() which posts to action url in a new pop up page.
Thanks
Jitendra
Share Improve this question asked Apr 18, 2011 at 8:21 RandomQuestionRandomQuestion 6,99818 gold badges66 silver badges100 bronze badges 3- 1 how do you want to create a popup? on different window or same window?? – S L Commented Apr 18, 2011 at 8:24
- check the answer provided it'll help you – Harish Commented Apr 18, 2011 at 8:51
- Thanks all for quick responses. Answers by wong2 and Anand works. – RandomQuestion Commented Apr 18, 2011 at 9:22
3 Answers
Reset to default 6Use this:
function submitFormInPopUp()
{
window.open('','Prvwindow','location=no,status=no,toolbar=no,scrollbars=yes,width=730,height=500');
document.test.action = "preview.jsp"
document.test.target = "Prvwindow"
document.test.submit();
}
i hope its help to u
function submitFormInPopUp(){
var url = "preview.jsp?email=" + document.getElementsByTagName('input')[0].value;
window.open(url);
}
Maybe you could use the target
attribute?
http://www.w3schools./TAGS/att_form_target.asp
Change the button type to submit
and specify target
, you don't need any javascript.
<form id="test" name="test" action="preview.jsp" target="_blank">
Email : <input type = "text" name = "email"/>
<input type="submit" value="Submit" id="submitButton" />
</form>
Be aware though it's deprecated and not allowed in Strict.
本文标签: javascriptHow to submit form in new pop up on button onclick actionStack Overflow
版权声明:本文标题:javascript - How to submit form in new pop up on button onclick action - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741422814a2377903.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论