duanne9313
2015-11-30 07:21
浏览 51

如何使用javascript / jquery使用多个确认对话框

Hello i want to put multiple confirm dialog on click of a button, Ex. when i click a button it shows "Are you sure?" with YES and NO, when i click YES another dialog box has to open with "want to notify users?" with YES and NO

<script>
 $('.deletes').click( function () {  
if (confirm( 'Are you sure? ' ) ) {  
window.location="<?php echo site_url('controller/method'); ?>";
if (confirm( 'want to notify users? ' ) )
{ 
window.location="<?php echo site_url('contoller/method22'); ?>";
} 

} });


</script>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • doudian6229 2015-11-30 08:17
    已采纳

    Use following code to redirect user after multiple confirmation

    step 1- add following line in html file

    <button id='open_dialog'>click</button>
    

    step 2- Add following line to the js file-

    jQuery('#open_dialog').click( function () {
    
        if (confirm( 'Are you sure? ' ) ) {
    
            if (confirm( 'want to notify users? ' ) ) {
                //use statement to redirect on particular page.
            }
        }
    
    })
    
    点赞 打赏 评论
  • douwen1006 2015-11-30 07:26

    It could be better if you put the code you have so far, anyway see example below :

    $('button').click( function () { 
      // first box, if yes then enter if block  
      if (confirm( 'Are you sure? ' ) ) {  
        // again came out 2nd box      
        if (confirm( 'want to notify users? ' ) ) {
            // do something
        }
     }    
    });
    

    DEMO

    点赞 打赏 评论

相关推荐 更多相似问题