我想要做的是,将模式框上每个复选框上选中的值返回到文本框。这个问题与这个问题非常相似,但问题的目的不同。所以请看看他们两个。:)
我有初始化模态框的代码:
<script>
var grid_modal_options = {
height: 'auto',
width: '80%',
modal: true
};
function showProductsModalBox() {
$("#products_modal_box").dialog(grid_modal_options);
$("#products_modal_box").parent().appendTo('form:first');
}
</script>
<div id="products_modal_box" title="Products" style="display: none;">
<div class="in">
<div class="grid-12-12">
<form id="products_modal_box_form" action="#" method="post">
<a href=\"javascript:;\" onclick=\"$('#products_id_textbox').val(\"input[name='checkedID[]']:checked\");$('#products_modal_box').dialog('close')();\">Submit</a>
<table>
<thead>
<tr>
<th> </th>
<th>Product</th>
</tr>
</thead>
<!-- Query for read mysql goes here (I skipped this line because it's not the main thing I'm gonna ask since it's run well) /-->
<tbody>
<?php
//read the results
while($fetch = mysqli_fetch_array($r)) {
print "<tr>";
print " <td><input type='checkbox' name='checkedID' value='" . $fetch[0] . "' /></td>"; //--> How to get the value of $fetch[0], collect it and return to a textbox?
print " <td>" . $fetch[0] . "</td>"; //$fetch[0] == Product ID
print "</tr>";
}
?>
</tbody>
</table>
</form>
</div>
</div>
</div>
正如您在上面看到的,我正在尝试使用伪选择器函数:input[name='checkedID[]']:checked
但未能返回值。还是我错过了代码?
这是返回在模式框上检查的值的文本框:
<input type='text' id='products_id_textbox' name='products_id_textbox' />
<a href='#' onclick='showProductsModalBox(); return false;'>Choose products</a>
能够显示模态框的代码。但是如何将用户从每个文本框中选择的“产品”返回到文本框products_id_textbox
?谢谢。