<tfoot id='CtZ0z'></tfoot>
  • <i id='CtZ0z'><tr id='CtZ0z'><dt id='CtZ0z'><q id='CtZ0z'><span id='CtZ0z'><b id='CtZ0z'><form id='CtZ0z'><ins id='CtZ0z'></ins><ul id='CtZ0z'></ul><sub id='CtZ0z'></sub></form><legend id='CtZ0z'></legend><bdo id='CtZ0z'><pre id='CtZ0z'><center id='CtZ0z'></center></pre></bdo></b><th id='CtZ0z'></th></span></q></dt></tr></i><div id='CtZ0z'><tfoot id='CtZ0z'></tfoot><dl id='CtZ0z'><fieldset id='CtZ0z'></fieldset></dl></div>

    <legend id='CtZ0z'><style id='CtZ0z'><dir id='CtZ0z'><q id='CtZ0z'></q></dir></style></legend>
    • <bdo id='CtZ0z'></bdo><ul id='CtZ0z'></ul>

    <small id='CtZ0z'></small><noframes id='CtZ0z'>

      1. 模态框 + 复选框 + cookie

        时间:2023-06-21
        <legend id='WSP9x'><style id='WSP9x'><dir id='WSP9x'><q id='WSP9x'></q></dir></style></legend>

            <tbody id='WSP9x'></tbody>

          <small id='WSP9x'></small><noframes id='WSP9x'>

              <i id='WSP9x'><tr id='WSP9x'><dt id='WSP9x'><q id='WSP9x'><span id='WSP9x'><b id='WSP9x'><form id='WSP9x'><ins id='WSP9x'></ins><ul id='WSP9x'></ul><sub id='WSP9x'></sub></form><legend id='WSP9x'></legend><bdo id='WSP9x'><pre id='WSP9x'><center id='WSP9x'></center></pre></bdo></b><th id='WSP9x'></th></span></q></dt></tr></i><div id='WSP9x'><tfoot id='WSP9x'></tfoot><dl id='WSP9x'><fieldset id='WSP9x'></fieldset></dl></div>
                  <bdo id='WSP9x'></bdo><ul id='WSP9x'></ul>
                  <tfoot id='WSP9x'></tfoot>
                  本文介绍了模态框 + 复选框 + cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想实现以下目标:

                  • 在主页加载时,显示模态框
                  • 在模态框中,显示一个带有单个必填复选框的表单
                  • 选中复选框,点击提交并关闭模式框,进入主页
                  • 使用 cookie 记住此复选框勾选首选项
                  • 在用户返回首页时,如果他们选中了复选框,模态框不会显示

                  我已经得到了这个:

                  http://dev.iceburg.net/jquery/jqModal

                  我可以在页面加载时显示模态框,但我不知道如何获取表单以使复选框成为强制性并关闭该框.设置cookie时我也不知道从哪里开始.

                  In that I can get the modal box displaying on page load, but I can't work out how to get the form to make the checkbox mandatory and close the box. I also don't know where to start when setting a cookie.

                  任何指针将不胜感激.

                  谢谢

                  包含代码:

                  Index.html - 在页面加载时显示模式框

                  Index.html - to display modal box on page load

                  $().ready(function() {
                    $('#ex2').jqm({modal: 'true', ajax: '2.html', trigger: 'a.ex2trigger' });
                  
                      setTimeout($('#ex2').jqmShow(),2000); 
                  
                  });
                  

                  2.html - 通过 ajax 加载的模态框内容

                  2.html - modal box content loaded via ajax

                  function validate(frm) {
                          if (frm.checkbox.checked==false)
                      {
                          alert("Please agree to our Terms and Conditions.");
                          return false;
                      }
                  }
                  
                  
                  <form action="" method="POST" onSubmit="return validate(form);" name="form">
                  <input type="checkbox" name="checkbox" id="checkbox" value="1">&nbsp;I hereby agree to all Terms and Conditions</a>
                  <input type="submit" value="Submit">
                  </form>
                  

                  推荐答案

                  加载 jquery cookie 插件以允许设置/读取 cookie:http://plugins.jquery.com/project/cookie然后..下面是这样的.未经测试,但你明白了

                  Load the jquery cookie plugin to allow to set/read cookies: http://plugins.jquery.com/project/cookie then.. something like this below. Untested, but you get the idea

                  index.html:

                  index.html:

                  $().ready(function() {
                      if (!$.cookie('agreed_to_terms'))
                      {
                          $('#ex2').jqm({modal: 'true', ajax: '2.html', trigger: 'a.ex2trigger' });
                          $('#ex2').jqmShow();    
                      }
                  });
                  

                  2.html:

                  $().ready(function()
                  {
                      $('#agreeFrm').submit(function(e)
                      {
                          e.preventDefault();
                  
                          if ($(this).find('input[name=checkbox]').is(':checked'))
                          {
                              $.cookie('agreed_to_terms', '1', { path: '/', expires: 999999 });
                              $('#ex2').jqmHide(); 
                          }
                      });
                  });
                  
                  <form id="agreeFrm" action="" method="POST" name="form">
                  <input type="checkbox" name="checkbox" id="checkbox" value="1">&nbsp;I hereby agree to all Terms and Conditions</a>
                  <input type="submit" value="Submit">
                  </form>
                  

                  这篇关于模态框 + 复选框 + cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在模态窗口中打开 Highcharts 下一篇:Javascript中的睡眠()

                  相关文章

                  <i id='sKWzV'><tr id='sKWzV'><dt id='sKWzV'><q id='sKWzV'><span id='sKWzV'><b id='sKWzV'><form id='sKWzV'><ins id='sKWzV'></ins><ul id='sKWzV'></ul><sub id='sKWzV'></sub></form><legend id='sKWzV'></legend><bdo id='sKWzV'><pre id='sKWzV'><center id='sKWzV'></center></pre></bdo></b><th id='sKWzV'></th></span></q></dt></tr></i><div id='sKWzV'><tfoot id='sKWzV'></tfoot><dl id='sKWzV'><fieldset id='sKWzV'></fieldset></dl></div>
                    <bdo id='sKWzV'></bdo><ul id='sKWzV'></ul>

                  1. <legend id='sKWzV'><style id='sKWzV'><dir id='sKWzV'><q id='sKWzV'></q></dir></style></legend><tfoot id='sKWzV'></tfoot>

                    1. <small id='sKWzV'></small><noframes id='sKWzV'>