/    Sign up×
Community /Pin to ProfileBookmark

javascript form alternate action opening TWO WINDOWS

I have a script choosing a second action on a form with one of two buttons calling the script that keeps opeing TWO new windows (and writing to my db twice! yeck!):

[CODE]
function OnButton1() {
document.form.action = “prev_post.php”
// document.form.target = “_blank”; // Open in a new window
document.form.submit(); // Submit the page
}

function OnButton2() {
document.form.action = “formProcess.php”
// document.form.target = “_blank”; // Open in a new window
document.form.submit(); // Submit the page
}
[/CODE]

with the form tag thus:
<form method=”post” name=”form” id=”form” />

and the buttons:

[CODE]<input type=”image” src=”images/preview.gif” border=”0″ name=button1 onClick=”OnButton1();”>
<input type=”image” src=”images/preview.gif” border=”0″ name=button2 onClick=”OnButton2();”>[/CODE]

can someone kindly tell me what the heck is going on, or perhaps show me a better way to accomplish this…?

Many thanks
GN

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 24.2008 — onclick="OnButton1(); r[COLOR="SeaGreen"]eturn false;[/COLOR]"
×

Success!

Help @glenn_php 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.20,
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,
)...