【发布时间】:2015-11-09 18:10:28
【问题描述】:
我想要的是在我的复选框的值中插入多个值,并将其发送到我的函数 myAlert(this) 中,只有一个字符串,如“code_dateAdded_...”
echo '<td><input type="checkbox" onclick="myAlert(this)" name="code" id="code" value="'.$donnees['code'].'_'.$donnees['dateAdded'].'"/>'.$donnees['code'].'</td>';
值应该是这样 value="355422_2015-07-30 03:00:16"
我尝试这样插入,但是当我对我的值进行回显时,我只得到 $donnees['code'] 的值,而不是像下划线和 $donnees['dateAdded'] 这样的值
功能:
function myAlert(str){
if (str == "") {
document.getElementById("valSup").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("valSup").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","myAlert.php?q="+str.value,true);
xmlhttp.send();
}
}
在 myAlert.php 中,我只对参数进行回显:
$q = intval($_GET['q']);
echo $q;
是否可以这样做,如果不能,我该怎么做
谢谢
【问题讨论】:
-
你的问题是什么
-
你在 db 中字段的数据类型是什么?
-
我的问题是在我的复选框的 value="" 中插入多个参数并将它们放入我的函数中
-
检查 $donnees 数组的 'dateAdded' 和 'code' 字段是否为空。制作
print_r($donnees)并查看结果 -
它们至少不是空的“代码”,因为当我回显这个 $donnees['code'].'_'.$donnees['dateAdded'] 我只得到 $donnees[ '代码']