开发者

Javascript confirm with checkboxes

Hi Here is my code to display the alert box:

    var answer = window.confirm ("The registration you have entered is illegal for the uk roads. By clicking ok you are accepting full resposibility for this plate and agreeing to use it for offroad use only.");

    if (answer) {
    //Tell them its a show plate
    $('#numberplateyellow').append(platetext);
    $('#numberplatewhite').append(platetext); 
    $('#illegal').append('Show Plate Not Road Legal');
    }else{
    $('#illegal').empty();
    }

  }else{
     //Its A Legal Plate
    $('#numberplateyellow').append(platetext);
    $('#numberplatewhite').append(platetext);  
  }

I wish for the wi开发者_如何学运维ndows.confirm to contain a checkbox that says check here if you agree to the terms and conditions.

How do i add a checkbox to the window.confirm ?

Thanks


You cannot add a checkbox to a confirm. You will have to make your own dialog for that to work.


Here is a fiddle demo using jQuery's dialog: http://jsfiddle.net/maniator/tRBEt/


You cannot edit default window feature, so there is no way you can add a checkbox in confirm or alert.

So what's the solution:

Implement your own: you may user intercept submit, create a modal pop that contains checkbox etc, whatever you need.


Instead of an alert style box generated in the browser (which is unlikely to support checkbox's unless their is a proprietary browswer way of doing it).... You may wish to consider a modal dialog box as it will give you more control.

A good implementation is jQuery-UI's dialog box: http://jqueryui.com/demos/dialog/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜