user2064189
user2064189

Reputation: 81

How to append the form field values to the variable dynamcially without reloading the page

How to append the Entered letters dynamically from the form to the variable in the query...

The code goes as follows....

    <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>

So here i just want append the "search" textbox values to the query('%#form.search#%') as soon as i type it without reloading the page or losing the focus of the form field....

Thank You in advance... :)

Upvotes: 1

Views: 143

Answers (2)

arvin_codeHunk
arvin_codeHunk

Reputation: 2390

<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);
})

Upvotes: 1

EnterJQ
EnterJQ

Reputation: 1014

<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);
})

Upvotes: 1

Related Questions