1
問題是我們不能從下拉框中選擇信息並將其發佈到我們的數據庫中。我們嘗試了許多事情,無法看到選定的下拉列表的值顯示在任何地方。對不起,第一次發佈堆棧溢出。jquery下拉併發布到sql數據庫問題
HTML和PHP的Dropbox
<div class="tl">
<center><br><? $sqltl = "SELECT * FROM till WHERE account ='$dbname' ORDER BY tillname ASC";
$resulttl = mysql_query($sqltl);
echo "<select id='tills' name='tills'>";
while ($rowtl = mysql_fetch_array($resulttl)) {
echo "<option value='" . $rowtl['tillname'] . "'>" . $rowtl['tillname'] . "</option>";
} echo "</select>"; ?><br>
<div class="pagination btn-group">
<div class="btn btn-medium highlight-color-0" id="floattl" style="width: 150px; height: 150px; margin: 0.5px; white-space: normal">
<div class="btn-image dollar-bill"></div>
<span class="btn-text">Float Till</span>
</div>
<div class="btn btn-medium highlight-color-0" id="closetl" style="width: 150px; height: 150px; margin: 0.5px; white-space: normal">
<div class="btn-image dollar-bill"></div>
<span class="btn-text">Close Till</span>
</div>
</div>
</center>
<div>Current Float Amount</div>
<div class="btn btn-small highlight-color-0" id="submit_float">Confirm</div>
<input type="text" id="tlfloat_num" style="width: 275px;">
</div>
的jQuery:
$('#floattl').click(function() {
tillselect = $("#tills option:selected").val;
$('#tlfloat_num').val(tillselect);
});
$('#submit_float').click(function() {
var tillfloat = $('#tlfloat_num').val;
var $openingamount = tillfloat;
//var $select_tilname = $('#tills').get(0).selectedIndex = 0;
//$('#tlfloat_num').val($openingamount);
//$('#tlfloat_num').val($tillselect);
$.post("till.php", {tlname: tillselect, openingamount: $openingamount, account: "<? echo $dbname; ?>"});
});