在javascript alert / confirm中插入html

时间:2013-06-12 06:21:45

标签: javascript

我正在编写验证代码,如果发生任何错误,则会出现确认或警告对话框。现在我想在警告对话框中保留一个复选框,如果选中该复选框,则应返回复选框上的值。我尝试使用jquery-modal对话框,但它没有帮助我。所以任何人都可以告诉我我该怎么做

2 个答案:

答案 0 :(得分:0)

Jquery模式为你完成这项工作。

下面是设置关闭复选框值的代码。

http://jsfiddle.net/RSk4v/

 $(function () {
 $("#dialog-confirm").dialog({
     resizable: true,
     height: 150,
     modal: true,
     close: function () {
         $(this).find(':checked').each(function () {
             var name = $(this).attr('name');
             $('input[name="' + name + '"]').val('checked '+name);
         });
     },
     buttons: {
         "Ok": function () {
             $(this).dialog("close");
         },
         Cancel: function () {
             $(this).dialog("close");
         }
     }
 });
 });

答案 1 :(得分:0)

如果我理解你的问题,我会做这个练习。

对于复选框的控件,您必须使用此脚本:

  if(document.getElementById("check1").checked=true)

DEMO