/    Sign up×
Community /Pin to ProfileBookmark

Submit form to a new windown

I would like to submit a form, have the response appear in a new window, be able to control the new window, and give the user the option to press enter instead of the submit button to submit the form. The following almost works, however, does not allow the new window to be controlled:

[code=html]<form action=”my_form_file.php” method=”post” target=_blank>
<input type=”submit” value=”Submit”>
<!– other forms go here –>
</form>[/code]

As an alternative, I am considering the following:

[code=html]<form id=”my_form” action=”my_form_file.php” method=”post”>
<input type=”button” value=”Submit” onclick=”submit_form();”>
<!– other forms go here –>
</form>[/code]

[CODE]function get_recipes() {
document.forms.my_form.submit();
window.open(“my_form_file.php”,””,”top=20,left=20,width-250,height=500, status, location, menubar, resizable,scrollbars,toolbar”);
}[/CODE]

I am having a difficult time getting this second approach working. Any suggestions? Also, this won’t allow the user to press enter to automatically submit (unless I add a bunch of javascript for each form field). Is there a better way to do this?

Thanks

to post a comment
HTML

4 Comments(s)

Copy linkTweet thisAlerts:
@FangFeb 04.2007 — &lt;form id="my_form" action="#" method="post" onsubmit="get_recipes();"&gt;
&lt;!-- other forms go here --&gt;
&lt;button type="submit"&gt;submit&lt;/button&gt;
&lt;/form&gt;

function get_recipes() {
window.open("my_form_file.php","","top=20,left=20,width-250,height=500, status, location, menubar, resizable,scrollbars,toolbar");
}
Copy linkTweet thisAlerts:
@CharlesFeb 05.2007 — AACK! You must be careful to not create a form that will not work at all for those of us that block pop-ups or JavaScript itself. And note, when you do open a new window there should be no white space in the geometry parameter.&lt;form action="my_form_file.php" target="child" onsubmit="window.open ('', 'child', 'height=400,width=300')"&gt;
Copy linkTweet thisAlerts:
@NotionCommotionauthorFeb 05.2007 — Thanks Fang and Charles.

Using both of your suggestions, my form input values do not appear to be posted to the server. Is there anything different that needs to be done to do so?

Also, Charles, please explain what you are doing with target="child" and the child in the window.open.

Thanks
Copy linkTweet thisAlerts:
@CharlesFeb 05.2007 — onsubmit="window.open ('', 'child', 'height=400,width=300')"Just before the form is submitted a new window is created, according to the specified geometry, and the window is named "child". target="child"Once the form is submitted the returned resource is displayed in some window named "child", if it exists. You could substitute other names for "child".
×

Success!

Help @NotionCommotion spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...