Tag: dynamicform

动态复制的表单在CodeIgniter重新加载时消失

我有以下代码需要重复: Name Email 重复/动态添加的元素将具有相同的Name[]和Email[]名称,但它们的ID将增加。 JavaScript是在下面,基于Josiah Ruddell的表单复制脚本 。 var template = $(‘#field-row-container #field-row-1’).clone(); window.addForm = function () { var parent = $(this).closest(‘.dynamic-rows’).attr(‘id’); var fieldRowCount = countRows(parent) + 1; var newFieldRow = template.clone().find(‘:input’).each(function () { var newId = this.id.substring(0, this.id.length – 3) + “[” + fieldRowCount + “]”; $(this).prev().attr(‘for’, newId); // update label for this.id = newId; […]

Rails表单:从以前选择的字段更改表单字段

我有两个这样的simple_form字段 : 我想仅在用户为第一个字段选择“是”时才显示第二个字段。 我的Jquery: $(function(){ $(“#rationcard”).change(function(){ if ($(“#rationcard”).val()==”Yes”){ $(“#rationcard_no”).show(); } else { $(“#rationcard_no”).hide(); } }) }) 我可以看到js文件被包含在页面的头部。 生成的HTML: Ration card Yes No Ration Card No. 但是动态字段不起作用。 这有什么不对? 或建议任何更好的方法来实现这一目标。