By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,382 Members | 1,623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,382 IT Pros & Developers. It's quick & easy.

onclick together with input type =submit

P: n/a
hi,

I've got a submit button, and when one clicks it, I want a confirm box
to pop up to make sure the user really wants that. The user is
supposed to be redirected to another url if he presses OK, and do
nothing if not. The way it works at the moment, is that the confirmbox
appears as it should, but whatever the user presses, the php code
continues to run. Any suggestions?

php:

echo "<INPUT type =\"submit\" name =\"test\"
ONCLICK=\"decision('sure?')\" value =\"Slett messe!\">
</TD></TR></form></table><br>";
function decision(message){
if (confirm(message)) window.location.href='http://www.vg.no';
}

obscurr
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"Obscurr" <ob*****@hotmail.com> wrote in message
news:44**************************@posting.google.c om...
hi,

I've got a submit button, and when one clicks it, I want a confirm box
to pop up to make sure the user really wants that. The user is
supposed to be redirected to another url if he presses OK, and do
nothing if not. The way it works at the moment, is that the confirmbox
appears as it should, but whatever the user presses, the php code
continues to run. Any suggestions?


You could replace the "submit" button with a "button" button and put

onClick="if (confirm('Really submit?')) { this.form.submit(); }"

that might work?
Jul 20 '05 #2

P: n/a

"Obscurr" <ob*****@hotmail.com> wrote in message
news:44**************************@posting.google.c om...
hi,

I've got a submit button, and when one clicks it, I want a confirm box
to pop up to make sure the user really wants that. The user is
supposed to be redirected to another url if he presses OK, and do
nothing if not. The way it works at the moment, is that the confirmbox
appears as it should, but whatever the user presses, the php code
continues to run. Any suggestions?


You could replace the "submit" button with a "button" button and put

onClick="if (confirm('Really submit?')) { this.form.submit(); }"

that might work?
Jul 20 '05 #3

P: n/a


Obscurr wrote:
hi,

I've got a submit button, and when one clicks it, I want a confirm box
to pop up to make sure the user really wants that. The user is
supposed to be redirected to another url if he presses OK, and do
nothing if not. The way it works at the moment, is that the confirmbox
appears as it should, but whatever the user presses, the php code
continues to run. Any suggestions?

php:

echo "<INPUT type =\"submit\" name =\"test\"
ONCLICK=\"decision('sure?')\" value =\"Slett messe!\">
</TD></TR></form></table><br>";
function decision(message){
if (confirm(message)) window.location.href='http://www.vg.no';
}


If you want to submit a form use
<form action="whatever.php" ...>
...
<input type="submit"
onclick="return confirm('Are you sure you want to submit the
form?');">

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.