javascript - jquery dropdown and posting to sql database issue -
the issue cant select information dropdown box , post our database. tried numerous things cant see value of selected dropdown display anywhere. sorry first time posting on stack overflow.
html , php dropbox
<div class="tl"> <center><br><? $sqltl = "select * till account ='$dbname' order 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; ?>"}); });
try:
var tillselect = $('#tills option:seclected').val(); ^^^
instead of line:
tillselect = $( "#tills option:selected" ).val;
you need () on line:
var tillfloat = $('#tlfloat_num').val; //var tillfloat = $('#tlfloat_num').val();
Comments
Post a Comment