dongnachuang6635 2017-09-06 19:01
浏览 46

在select <option> [closed]的字符串中检索php变量

I need to retrieve one php variable in jQuery(The $foods['price']),but there is another variable and parenthesis on the left and the right of the variable.I tried to place the the php variable between the parenthesis text() in the jquery file but not success. How can I retrieve only the variable($foods['price'] ? I placed the screenshot below

Thanks in advance

enter image description here

  • 写回答

2条回答 默认 最新

  • douzheng9221 2017-09-06 19:33

    It's generally not acceptable to have a span inside the option tag, it's not valid html.

    Looking at your code you should apply a data attribute or a value to your options instead.

    For example,

    <select id="eat" class="form-control">
    <?php foreach($foods as $key => $food) { ?>
        <option value="<?=$food['price'];?>"><?=$food['name'];?> - <?=$food['price'];?></option>
    <?php } ?>
    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥20 大华dss监控平台网络关闭登不进去
  • ¥15 有关AT89C51单片机问题
  • ¥15 请使用蚁群算法解决下列问题,并给出我完整的代码
  • ¥20 关于php录入完成后,批量更新数据库
  • ¥15 请教往复密封润滑问题
  • ¥15 cocos creator发布ios包
  • ¥15 comsol压电材料数据
  • ¥35 用python实现除法算法中goldschmidt算法
  • ¥15 汇编代码转换成C代码
  • ¥15 除法算法中的归一化具体是怎么变的?