如何获得动态填充的“选择”按钮的选项值,以便可以用来获取数据库中所需的值。我不知道如何获得$giftName
价值。我尝试使用jquery和javascript,但是我不知道如何将其集成到我的代码中,因为我仍然不熟悉这种语言。这是我的代码的一部分,可能会帮助您:
<div class="row ml ">
<div class="col-lg-6 ">
<select id="giftList" name=''gifts" class="pull-left mb">
<option value=""></option>
<?php
$sendGiftSql = mysql_query("SELECT * FROM gifts WHERE isDelete = 'false' ORDER BY price ");
while($sendGift = mysql_fetch_assoc($sendGiftSql)){
$giftName = $sendGift['name'];
echo("
<option value =". $giftName.">" . $giftName. "</option>;
");
}
?>
</select>
</div>
<div class="col-lg-6">
<b style="float: right;">Cost://This is where the value of the select button will be used...
</div>
</div>
改变这个
<option>" . $giftName. "</option>;
至
echo("<option value =". $giftName.">" . $giftName. "</option>");
之后,您可以使用来获取选定的值$('#giftList')
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句