dsjj15012 2015-09-25 10:00
浏览 38

Bootstrap-combobox值不在PHP中发布

I am using this Bootstrap combobox plugin (https://github.com/danielfarrell/bootstrap-combobox) which is working fine. The only problem I have is that it does not post the value of the selected item in my MySQL database. All items in my form post well except the value of this combobox which always posts as zero (0). This is my javascript:

<script type="text/javascript">
      //<![CDATA[
        $(document).ready(function(){
          $('.combobox').combobox()
        });
      //]]>
    </script>

and this is my html select:

<div class="form-group">
<label for="Site">Site:</label>
<div class="form-group">

<?php 

require "config.php";
$con = mysql_connect(DBSERVER,DBUSER,DBPASS);
mysql_select_db(DBNAME, $con);

$sql = "SELECT * from  `b17_16413362_upupa`.`site`";
$result = mysql_query($sql);

echo "<select id='Site' name='Site' class='combobox input-large form-control'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='". $row['id'] ."'>" . $row['code'] . " " . $row['site'] . "</option>";
                            }
echo "</select>";

?>
</div>
</div>

However I notice that when I change <select id="Site" name="Site" class="form-control combobox input-large"> to <select id="Site" name="Site" class="form-control"> it posts but, of course, without the auto-complete feature. So how can I integrate these two to have an autocomplete combobox that posts?

  • 写回答

1条回答 默认 最新

  • duandaijian1583 2015-09-25 10:18
    关注

    If you are using Ajax to put the data into the database, then you can get value of the input box with class combobox using simple JS as :

    var boxValue = document.getElementById('site').value;
    

    Then, you can use this JS variable to post data into your database.

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?