jQueryflexdatalist不会在相同形式的多个字段上显示数据

时间:2018-10-15 04:31:47

标签: javascript php jquery

我在我的项目中使用jQueryflexdatalist。

我正在尝试从数据库中获取一种表单上两个不同字段的数据。

HTML部分为:

<div class="form-group">
              <div class="form-label-group">
                 <input type='text'
                     placeholder='Name'
                     class='flexdatalist form-control'
                     data-search-in='first_name'
                     data-visible-properties='["first_name","other_names","email"]'
                     data-selection-required='true'
                     data-value-properties='user_id'
                     data-min-length='1'
                     name='text_user'
                     id="text_user"
                     required>
              <label for="text_user">Students Name:</label>
              </div>
            </div>



            <div class="form-group">
              <div class="form-label-group">
                <input type='text'
                     placeholder='country'
                     class='flexdatalist form-control'
                     data-search-in='country_name'
                     data-visible-properties='["country_code","country_name"]'
                     data-selection-required='true'
                     data-value-properties='country_id'
                     data-min-length='1'
                     name='text_country'
                     id="text_country"
                     required>
              <label for="text_country">country Name:</label>
              </div>
            </div>

页脚附带的脚本是

<script type="text/javascript">
        $('.flexdatalist').flexdatalist({
             minLength: 1,
             textProperty: '{first_name}, {other_names}, {email}',
             valueProperty: 'user_id',
             selectionRequired: true,
             visibleProperties: ["first_name","other_names","email"],
             searchIn: 'first_name',
             data: 'ajax_users.php'
          }); 
    </script>


     <script type="text/javascript">

        $('.flexdatalist').flexdatalist({
             minLength: 1,
             textProperty: '{tutor_fname}, {tutor_state}',
             valueProperty: 'tutor_id',
             selectionRequired: true,
             visibleProperties: ["tutor_fname","tutor_state"],
             searchIn: 'tutor_fname',
             data: 'ajax_country.php'
}); 
    </script>

我已经验证了从数据库中获取数据的php代码,它工作正常。 我真的不能指出问题出在哪里。

请帮忙。

0 个答案:

没有答案