【发布时间】:2015-08-06 16:43:35
【问题描述】:
我无法从复选框中获取值到我的数据库中,它在提交到数据库时只是显示为“数组”。
这里是我的代码的 sn-ps,说明了我正在尝试做的事情:
HTML:
<input type="checkbox" name="commentType[]" id="Streams_Wetlands" value="Streams_Wetlands">
<input type="checkbox" name="commentType[]" id="Vegetation" value="Vegetation">
JS:
var commentType = new Array();
$('input:checkbox[name="commentType[]"]').each(function() {
commentType.push($(this).val());
});
postData( "php/add1.php",{
CommentAddress1: commentAddress1,
UserAddress1: userAddress1,
CommentType1: commentType,
CommentTypeOther1: commentTypeOther1
});
PHP:
$q .= " . $_POST['UserAddress1'] . "','" . $_POST['CommentType1'] . "','" . $_POST['CommentTypeOther1'] . "','" . $_POST['CommentAddress1'] . ";
【问题讨论】:
标签: javascript php arrays forms