jquery下拉列表和发布到SQL数据库问题


jquery dropdown and posting to sql database issue

问题是我们无法让它从下拉框中选择信息并将其发布到我们的数据库中。我们尝试了许多看不到的东西,以获取所选下拉列表的值以显示在任何地方。抱歉第一次在堆栈溢出上发布。

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>

j查询:

$('#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; ?>"});
});

尝试:

var tillselect = $('#tills option:seclected').val();
                                                 ^^^

而不是这一行:

tillselect = $( "#tills option:selected" ).val;

您还需要此行上的 ():

var tillfloat = $('#tlfloat_num').val;
//var tillfloat = $('#tlfloat_num').val();