绑定动态填充的<select>以生成第三个

时间:2016-12-24 18:05:05

标签: javascript php jquery select

我试图在表单中创建一系列下拉列表。第一个选择是填充第二个表单,但我无法从结果中调用第三个表单。我已经想出(我认为)这是一个具有约束力的问题,但我该怎么做才能纠正这个问题。 页面上的JavaScript: &LT;脚本&GT;       var selected_form_div = null;       var frm_submit_event = function(e){             var $ this = $(this); // 按钮             // var frm = $ this.closest(form);             var frm = $(&#39;#&#39; + selected_form_div +&#34; form&#34;);             的console.log(FRM);             的console.log(frm.serialize());              e.preventDefault();             $就({                 键入:&#34; POST&#34;,                 url:&#34; classes / forms / ajaxPost.php&#34;,                 data:frm.serialize(),                 dataType:&#34; text&#34;,                 成功:函数($ result){                 // var obj = jQuery.parseJSON(data);如果未将dataType指定为json取消注释                             $(&#39;#&#39 + selected_form_div)的.html($结果);              },             错误:function(){                 提醒(&#39;错误处理&#39;);             }         });       }     function loadSubSelects(value,form,select) {   $ .post(&#34; classes / forms / update_form.php&#34;,{catid:value,form:form,select:select},function(data)                  {                   jQuery的(&#39;# - 行业标准&#39;)HTML(数据)。                                          }); }     $(文件)。就绪(函数(){         $(&#39; ._ form_selector&#39;)。点击(函数(E){             e.preventDefault();             var $ this = $(this);             $ .get(&#39; classes / forms / forms.php&#39;,{                 形式:$(this).attr(&#39; form_data&#39;)             },             函数($结果){                 $(&#39;#&#39; + $ this.attr(&#39; form_div&#39))。HTML($结果);                 // selected_form_div = $ this.closest(&#34; form&#34;);                 selected_form_div = $ this.attr(&#39; form_div&#39;);                 //console.log($result);             });             的console.log($(本).attr(&#39; form_data&#39;));         });         $(document).on(&#34; click&#34;,&#39; .frm_submit_btn&#39;,frm_submit_event);         $(&#39; ._薪酬&#39;)点击(函数(){。             var $ this = $(this);             的console.log($ this.attr(&#39; form_id&#39;));             $(&#39; ._ form_pay&#39;)。css(&#39; display&#39;,&#39; none&#39;);             $(&#39; #form _&#39 + $ this.attr(&#39; form_id&#39)+&#39; _pay&#39)的CSS(&#39;显示&#39;&# 39;块&#39);         });  });         function showForms(form,click_listen){             jQuery.noConflict();             jQuery(&#39; form&#39;)。hide(); //最初隐藏  jQuery的(&#34;#click_listen&#34)。单击(函数(E){    jQuery(form).toggle(&#39; fast&#39;); //或只显示而不是切换  });         }         function reportError(request){alert(&#34; Something Went Werong,请提交支持服务单。&#34;);}     &LT; /脚本&GT; 和LoadSubSelects是有问题的函数,PHP结果: 我想在结果中绑定什么(我认为) PHP代码: $ query =&#34; SELECT letter_id,letter_title FROM letter_template其中letter_category_id = $ catid&#34 ;; $ result = mysql_query($ query)或die(mysql_error()); echo&#39;&lt; select name =&#34; sselect1&#34;类=&#34; E1&#34; style =&#34; width:100%!important;身高:1.85em!重要;颜色:#a8a8a8!重要; border-color:#d7d7d7! onChange =&#34; loadSubSelects(this.value,\&#39; write_letter \&#39;,this.name)&#34;&gt;&lt; option value =&#34; 0&#34;&gt; Please选择A Letter&lt; / option&gt;&#39 ;; //打印列表框选择命令 而($ catinfo = mysql_fetch_array($结果)){ //存储在$ nt中的数组或记录   echo&#34;&lt; option value = \&#34;&#34; .htmlspecialchars($ catinfo [&#39; letter_id&#39;])。&#34; \&#34;&gt;&#34 ; $ catinfo [&#39; letter_title&#39;]&#34;&LT; /选项&GT;&#34 ;; } 回声&#34;&LT; /选择&GT;&#34 ;; echo htmlspecialchars($ catinfo [&#39; letter_id&#39;]); 任何帮助都将非常感谢,非常感谢:)

0 个答案:

没有答案