You have to return false if you want the submission to be cancelled. I'm confused about you setting window.location -- are you trying to have the form submit somewhere else? You need to change the form's action for that.
On Wed, Apr 15, 2009 at 7:15 AM, Arvin <[email protected]> wrote: > > Hi, I've been using cake for about 5 months now. I'm not really > familiar with cake's advanced features though I somehow managed to > come up with a decent Document Management System for use in a research > company. > > I would like to know how I could add a javascript confirm dialog box > when submitting forms. I tried this one but it seems that after going > through the if/else statements, the page (and filled-up fields) would > still be submitted regardless of the answer on the confirm box. I was > hoping for a confirm box that would 'confirm' my action first. If > 'yes' then submit the fields, else, stay on the current page. I guess > cake has a different way of doing this? Any help would be > appreciated. > > <script type="text/javascript"> > function confirmation() { > var answer = confirm("Are you sure?") > if (answer){ > window.location = "redirect_url_page"; > } > else{ > } > } > > </script> > > <?php echo $form->end('Submit'); ?> > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
