jquery - 在 jQueryUI 对话框中包含部分表单

标签 jquery forms jquery-ui

我的代码如下所示:

<form id="MyForm" name="MyForm" method="post" action="index.php">

<input type="text" id="Input1" name="Input1">
<input type="text" id="Input2" name="Input2">

<div id="dialog">
<input type="text" id="Input3" name="Input3">
<input type="text" id="Input4" name="Input4">
</div>

<button type="button" onclick="$('#dialog').dialog('open');">Fill out 3 and 4</button>
<input type="submit" value="Submit">

</form>

我可以将表单的第二部分放在 JQueryUI 对话框中,Input3 和 Input4 不会出现在 POST 数据中。可以这样做吗?

最佳答案

编辑为不指定输入名称。

$('#dialog').bind('dialogclose', function(event, ui) {
    $('#dialog :input').each(function(index) {

      $("#myForm").add('<input>').attr({
        type: 'hidden',
        id: $(this).attr('id')
      });
    });
});

关于jquery - 在 jQueryUI 对话框中包含部分表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2339672/

相关文章:

javascript - 我怎样才能扩展这个?

asp.net - 为什么 DropDownList.SelectedValue 依赖于 viewstate?

css - 如何垂直居中图标

javascript - 当数据相同的 Highcharts 时,如何使情节线出现在折线图上?

javascript - 如何使用 jquery 切换 3 种背景颜色

javascript - 联系表单的 AJAX POST 返回 500 错误

javascript - 使用 jQuery 让 Vue 知道数据改变

jquery - 使用 jQuery UI 自动完成和选项卡 - 修改后的 CSS 冲突

javascript - 悬停时如何使此功能无限

javascript - 提交前更新空表单字段