无法填充表单字段

时间:2016-08-30 13:07:12

标签: javascript jquery forms jsp

我正在主要表单中输入包含复选框的输入。 在提交表单之前,我会显示一个弹出窗口以确认提交。

我无法填充弹出窗口中的复选框字段

var target = jQuery ('div#confirm_popup div.content');

用于填充弹出窗口的代码:

target.find('randomCheckboxMain').html(form_table.find('#randomCheckbox:checked').val());

在这里,我找到主窗体中的复选框,然后获取其值并填充弹出窗口。

这是我的主要表单复选框,它是表格的一部分,其中id =" form_table"

<table id="form_table">
....
....
<tr>
    <td class="field_head">checkh:</td>
    <td>
        <html:checkbox property="prop" name="randomCheckboxMain" value="yes" disabled="true"></html:checkbox>
    </td>
</tr>

这是我的弹出字段

        <tr>
            <td class="head">checkValue:</td>
            <td class="randomCheckbox"></td>
        </tr>

任何人都可以告诉我我做错了什么。

3 个答案:

答案 0 :(得分:0)

您在class

中使用<td class="randomCheckbox"></td>

所以:

改变:

.html(form_table.find('#randomCheckbox:checked').val());

致:

.html(form_table.find('.randomCheckbox:checked').val());

答案 1 :(得分:0)

你的td中有一个类,但你在jQuery中有id。

答案 2 :(得分:0)

target.find('.randomCheckbox').html(
      form_table.find('[name="randomCheckboxMain"]').val());

为复选框提供ID或类,以便检查是否已选中。