【发布时间】:2014-08-30 22:44:19
【问题描述】:
在此示例中,alert(selectedString) 检索下拉选择值,因此我知道这部分有效。我想采用该值并使用它来查询带有 mysqli 和 PHP 的表。我们如何使用选定的字符串查询数据库表?
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
var select = document.getElementById("test");
select.onchange = function(){
var selectedString = select.options[select.selectedIndex].value;
alert(selectedString);
}
</script>
【问题讨论】:
-
您需要使用 AJAX 调用 php 脚本并将所选字符串作为数据参数传递。然后,您可以回显查询的结果数组,然后使用成功回调的结果更新您的 Dom
标签: javascript php jquery mysqli