微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

隐藏字段的特殊表单提交问题

如何解决隐藏字段的特殊表单提交问题

我的表格很长,提交时遇到问题。用户在下拉菜单中有几个选项。根据他们的选择,使用“ .hide()”将某些HTML块从视线中删除。这一切都按预期工作。问题是,如果隐藏了这些HTML代码块,则表单将不会提交。如果我使用浏览器工具并删除每个隐藏的HTML块,则表单可以完美提交。我尝试使用“ .remove()”隐藏这些HTML块,但是问题是,如果用户决定返回并更改表单选项,则无法恢复它。我还在这些HTML块上尝试了“ .detach()”,但如果append函数页面上的其他位置,则它不起作用。我以为也许我需要禁用这些相应的HTML块中的输入。但是,这没有什么区别。我还尝试将HTML块的整个块压缩为一行(可怕的浪费性多余和重复),并加载为“ innerHTML”。但是,这些HTML块中有一些“ bracket?PHP echo?bracket”元素,这些元素在此简明的HTML行中不起作用。在隐藏的HTML代码块中,是否有人知道如何提交表单?顺便说一句,我正在使用parsely在用户端进行验证。

我的第二个选择是使用“ .remove()”,但要弄清楚如何在单击刷新按钮时替换HTML和PHP echo内容。 “ .remove()”确实可以通过删除我手动删除内容来工作。但是,如果用户决定通过单击重置按钮来擦除所有输入,并将用户穿梭到表格的开头,则我无法替换所有HTML块。如果有人知道如何将所有HTML代码块(如下所示)还原到点击时的开始位置,那也将起作用。

 $(document).ready(function() {

     var $sections = $('.form_section');

     function navigateto(index) {

       //Mark the current section with the class 'current'
       $sections
         .removeClass('current')
         .eq(index)
         .addClass('current');

       //Show only the navigation buttons that make sense for the current section:
       $('.form_navigation2 .prevIoUs').toggle(index > 0);
       var atTheEnd = index >= $sections.length - 1;
       $('.form_navigation1 .submit_button').toggle(!atTheEnd);
       $('.form_navigation2 [type=submit]').toggle(atTheEnd);
     }

     function curIndex() {
       //Return the current index by looking at which section has the class 'current'
       return $sections.index($sections.filter('.current'));
     }


     $('.form_navigation2 .prevIoUs').click(function() {
           navigateto(curIndex() - 1);
           $('#the_form').reset;

           $('.form_navigation1 .submit_button').click(function() {
             $('#the_form').parsley().whenValidate({
               group: 'block-' + curIndex()
             }).done(function() {
               navigateto(curIndex() + 1);
             });

             //If I remove these hidden chunks of HTML in the browser tools the form submits fine.
             //I have tried .remove(),but unable to restore.
             //I have tried .detach(),also unable to restore.
             //Hide/show works but form does not submit.        
             if ($('.part1').val() == 'option1') {
               $('.group2,.group3,.group5').hide();
               $('#input2,#input3,#input5').prop("disabled",true);
             }
             if ($('.part2').val() == 'option2') {
               $('.group1,.group2,.group5').hide();
               $('#input1,#input2,true);
             }

             //Prepare sections by setting the `data-parsley-group` attribute to 'block-0','block-1',etc.
             $sections.each(function(index,section) {
               $(section).find(':input').attr('data-parsley-group','block-' + index);
             });
             navigateto(0); //Start at the beginning
           });
       });
     $(document).ready(function() {

 var $sections = $('.form_section');

 function navigateto(index) {

   //Mark the current section with the class 'current'
   $sections
     .removeClass('current')
     .eq(index)
     .addClass('current');

   //Show only the navigation buttons that make sense for the current section:
   $('.form_navigation2 .prevIoUs').toggle(index > 0);
   var atTheEnd = index >= $sections.length - 1;
   $('.form_navigation1 .submit_button').toggle(!atTheEnd);
   $('.form_navigation2 [type=submit]').toggle(atTheEnd);
 }

 function curIndex() {
   //Return the current index by looking at which section has the class 'current'
   return $sections.index($sections.filter('.current'));
 }


 $('.form_navigation2 .prevIoUs').click(function() {
       navigateto(curIndex() - 1);
       $('#the_form').reset;

       $('.form_navigation1 .submit_button').click(function() {
         $('#the_form').parsley().whenValidate({
           group: 'block-' + curIndex()
         }).done(function() {
           navigateto(curIndex() + 1);
         });

         //If I remove these hidden chunks of HTML in the browser tools the form submits fine.
         //I have tried .remove(),but unable to restore.
         //I have tried .detach(),also unable to restore.
         //Hide/show works but form does not submit.        
         if ($('.part1').val() == 'option1') {
           $('.group2,.group5').hide();
           $('#input2,true);
         }
         if ($('.part2').val() == 'option2') {
           $('.group1,.group5').hide();
           $('#input1,true);
         }

         //Prepare sections by setting the `data-parsley-group` attribute to 'block-0',etc.
         $sections.each(function(index,section) {
           $(section).find(':input').attr('data-parsley-group','block-' + index);
         });
         navigateto(0); //Start at the beginning
       });
     });
   });
 });

  //HTML Chunks look like this
  <div class="group2">
    <label for"calendarPicker_2A">selection 1</label>
    <div id="error_field_2A">
    </div>
    <p><input type="text" id="calendarPicker_2A" class="calendarsPicker cpDate" name="date2" value="<?PHP echo escape(Input::get('date2'));?>" maxlength="10" required="" data-parsley-required-message="required" data-parsley-pattern="^[0-9]{4}-[0-9]{2}-[0-9]{2}$" data-parsley-pattern-message="invalid format" data-parsley-errors-container="#error_field_2A" data-parsley-trigger="keyup"></p>
  </div>

解决方法

您要排除UINavigationBar.appearance().isTranslucent = false 个字段:pgrep -af python

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。