Connecting Tech Pros Worldwide Help | Site Map

onclick together with input type =submit

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 20th, 2005, 08:50 AM
Obscurr
Guest
 
Posts: n/a
Default onclick together with input type =submit

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

  #2  
Old July 20th, 2005, 08:50 AM
Daniel
Guest
 
Posts: n/a
Default Re: onclick together with input type =submit


"Obscurr" <obscurr@hotmail.com> wrote in message
news:4452c409.0307030358.228d2071@posting.google.c om...[color=blue]
> 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?
>[/color]

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

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

that might work?


  #3  
Old July 20th, 2005, 08:50 AM
Daniel
Guest
 
Posts: n/a
Default Re: onclick together with input type =submit


"Obscurr" <obscurr@hotmail.com> wrote in message
news:4452c409.0307030358.228d2071@posting.google.c om...[color=blue]
> 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?
>[/color]

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

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

that might work?


  #4  
Old July 20th, 2005, 08:50 AM
Martin Honnen
Guest
 
Posts: n/a
Default Re: onclick together with input type =submit



Obscurr wrote:[color=blue]
> 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';
> }
>[/color]

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/

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.