1

入力した文字をフォームからクエリの変数に動的に追加する方法...

コードは次のようになります。

    <cfquery name="select" datasource="#xxxx#" dbtype="ODBC">
      select xxxxx from yyyy where xxxxx like '%#form.search#%'
    </cfquery>


    <cfset head=#ValueList(MyQuery.pname,",")#>
    <cfset head1=#listtoarray(head)#>

   <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
   <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
   <script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
   <link rel="stylesheet" href="/resources/demos/style.css" />
   <script>

  $(function() {
  var states = <cfoutput>#serializeJson(head1)#</cfoutput>;
  $("#k").autocomplete({
  source:states
  });
  });
 </script>

 <form action="/" method="get" id="searchForm">
   <input type="text" name="search" id="search">
 </form>

したがって、ここでは、ページをリロードしたりフォームフィールドのフォーカスを失ったりせずに、入力するとすぐに「検索」テキストボックスの値をクエリ('%#form.search#%')に追加したいと思います。

前もって感謝します... :)

4

2 に答える 2

1
<cfquery name="select" id="select" datasource="#xxxx#" dbtype="ODBC">
  select xxxxx from yyyy where xxxxx like '%#form.search#%'
</cfquery>

$('#inputId').keyup(function (){
 var data = $('#inputId').val();
 $('#select').append(data);
})
于 2013-02-13T05:21:32.587 に答える
1
<input type="text" name="search" id="search"> //search is your element-id

<cfquery name="select" id="select" datasource="#xxxx#" dbtype="ODBC"/>

$('#search').keydown(function (){
 var data = $('#search').val();
 $('#select').append(data);
})
于 2013-02-13T05:26:47.603 に答える