当我在数据库中存在的url中输入实际的var
选项时,我可以让这个弹出窗口返回正确的值。
<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填充选择器下拉列表。
zones.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'};
}
?>
答案 0 :(得分:1)
示例代码正确:
$.get('http://stackoverflow.com/questions/tagged/' + 'javascript', function(data){
alert(data);
})
这是您需要的代码。 Javascript是一种客户语言
$.get('logbookincludes/sqftpoles.php?choice=' + $("#item36_select_1").val(), function(data){
alert(data);
});
function updatesub(){
$.get('logbookincludes/sqftpoles.php?choice=' + $("#item36_select_1").val(), function(data){
var u = $('#item44_number_1').val()-0,
q = $('#sqftofzone').val()-0,
n = data-0;
$('#item49_number_1').val(u*q*n);
alert(data);
});
}