亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

JQUERY 自動完成文本函數,該函數從 html 形式的其他文本獲取輸入

JQUERY 自動完成文本函數,該函數從 html 形式的其他文本獲取輸入

PHP
狐的傳說 2023-11-04 20:51:38
您好,我想從一個輸入字段讀取文本值,然后在 JQUERY 函數中使用它從數據庫獲取數據我希望像這樣填充源:/search/batch_name_by_barnID/1,但輸出類似于:/batch_name_by_barnID?項=1我如何設置這部分:source: "/search/batch_name_by_barnID/"+$('#barn_id').text(),以獲得像 /search/batch_name_by_barnID/{number} 而不是 /search/batch_name_by_barnID?term 的輸出? =1我的 HTML 是:    <input type="text" class="form-control search_occupied_barn_name" placeholder="Type here ..." name="barn_name">      <span class="help-block search_occupied_barn_name_empty" style="display: none;">No Results Found ...</span>      <input type="text" class="search_barn_id" name="barn_id" id="barn_id">      <label>????</label><br>      <input type="text" class="form-control search_batch_name_barn" placeholder="Type here ..." name="BatchName">      <span class="help-block search_batch_name_barn_empty" style="display: none;">No Results Found ...</span>      <input type="text" class="search_batch_id" name="batch_id" id="batch_id">我的 JQUERY 是: $( ".search_batch_name_barn" ).autocomplete({       source: "/search/batch_name_by_barnID/"+$('#barn_id').text(),       minLength: 1,       response: function(event, ui) {             if (ui.content.length === 0) {                 $(this).parent().addClass('has-error');                 $(this).next().removeClass('glyphicon-ok').addClass('glyphicon-remove');                 $(".search_batch_name_barn_empty").show();                 $('.form_submit').hide();             } else {                 $(".search_batch_name_barn_empty").hide();                 $('.form_submit').show();             }         },       select: function(event, ui) {         $('.search_batch_id').val(ui.item.id);         $('.search_batch_name_barn').val(ui.item.value);         }     });
查看完整描述

1 回答

?
catspeake

TA貢獻1111條經驗 獲得超0個贊

我找出了問題所在:我添加了一個按鈕,然后使用搜索方法代碼從該按鈕觸發了“search_batch_name_barn”的自動完成:default.js


  $("#getBatch").click(function () {

     alert("test");

     $(".search_batch_name_barn").show();

     $(".search_batch_name_barn").autocomplete('search');

  });

超文本標記語言


      <input type="text" class="form-control search_occupied_barn_name" placeholder="Type here ..." name="barn_name">

      <span class="help-block search_occupied_barn_name_empty" style="display: none;">No Results Found ...</span>

      <input type="hidden" class="search_barn_id" name="barn_id" id="barn_idorg">

      <button type="button" class="btn btn-primary" name ="getBatch" id="getBatch">Get Batch</button>

      <label>????</label><br>

      <input type="text" class="form-control search_batch_name_barn" placeholder="Type here ..." name="BatchName">

      <span class="help-block search_batch_name_barn_empty" style="display: none;">No Results Found ...</span>

      <input type="hidden" class="search_batch_id" name="batch_id" id="batch_id">


查看完整回答
反對 回復 2023-11-04
  • 1 回答
  • 0 關注
  • 168 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號