嗨,大家好我如何通过Ajax Call发送<select mutiple>
标签的值?谢谢
我的<select multiple>
标记在这里
<select multiple name='user[]' onchange="showUser(this.value)">
<option value="1"> User 1 </option>
<option value="2"> User 2 </option>
</select>
此处为<script>
代码
function showUser(str) {
if (str == "") {
document.getElementById("txtHint").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("txtHint").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
}
我想从我的后端发送多个值(getuser.php)然后我通过MYSQL SELECT()调用它,回到我的html页面并将其显示给我的index.php <select>
标签< / p>
喜欢这个<html>
Index.php
<select id="txtHint">
<option> 1 = select[value=1] </option>
<option>2 = select[value=2]</option>
</select>
注意:这些代码仅适用于单 <select>
标记但不适用于多个,如何在< em> Mutiple Select Tag ?
谢谢你们