var
当我在数据库中存在的 url 中键入实际选择时,我可以让这个弹出窗口返回正确的值。
<script type="text/javascript">
var data = $.get("logbookincludes/sqftpoles.php?choice=Front Range", function(data) {
alert("Data Loaded: " + data);
});
</script>
我希望变量由实际的下拉选择器设置id
。我似乎无法使语法正确。
var data = $.get("logbookincludes/sqftpoles.php?choice=" + $("#item36_select_1").val());
这是用于填充选择器下拉列表的服务器端 php。
zone.php
<?php
include("dbinfo.php");
$query = "SELECT zonename FROM zone";
$result=mysql_query($query);
while ($row=mysql_fetch_array($result)) {
echo "<option>" . $row{'zonename'} . "</option>";
}
?>
这是下拉代码。
Zone
<select name="zone" id="item36_select_1" required data-hint="">
<option id="item36_0_option" selected value="Front Range">
Front Range
</option>
<? include('logbookincludes/zones.php');?>
</select>
这是sqftpoles.php
<?php
include("dbinfo.php");
$choice = mysql_real_escape_string($_GET['choice']);
$query = "SELECT sqftpoles FROM zone WHERE zonename = '$choice'";
$result=mysql_query($query);
$result2=mysql_query($query2);
while ($row=mysql_fetch_array($result)) {
echo $row{'sqftpoles'};
}
?>