Click here to Skip to main content
16,004,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My code doesnt work.. the option that should be display wont appear.Please Help me
here my code
in html:
<input id="txtSearchTag">

C#
function textSearchDdl()
{
    var a;
        jQuery(function(){
          a = $('#txtSearchTag').autocomplete({
             width: 300,
             delimiter: /(,|;)\s*/,
             lookup: 'January,February,March,April,May,June,July,August,September,October,November,December'.split(',')
          });
         //a.setOptions({ lookup: 'January,February,March,April,May,June,July,August,September,October,November,December'.split(',') });
        });
}


and i already include this code in html head section:
<script src="jquery.autocomplete.js" type="text/javascript"></script>
Posted

1 solution

It looks like you have copy-pasted the stuff from some where. Your way of using the autocomplete for fixed array is incorrect.

Try this:
XML
<input id="txtSearchTag">

JavaScript
//directly put this in a script tag. 
var a2;
a2 = $('#months').autocomplete({
      width: 300,
      delimiter: /(,|;)\s*/,
      lookup: 'January,February,March,April,May,June,July,August,September,October,November,December'.split(',')
    })


This is NOT needed: jQuery(function(){

Done!
 
Share this answer
 
Comments
MissNano 27-Apr-11 4:53am    
yeah tried it before but it doesnt working that why im using it.. or the code is different if using in user control?
Sandeep Mewara 27-Apr-11 5:07am    
Works perfectly fine for me. I tried it.

You surely must be doing something different. If in usercontrol, make sure the JS file reference is correct and autocomplete js file is in place where it expects.
MissNano 27-Apr-11 21:45pm    
hahah silly mistake forgot to add the css file... and i should called the function in document.ready.. Thnx a lot Sandeep...
Sandeep Mewara 28-Apr-11 0:29am    
Good to know it helped.
MissNano 27-Apr-11 21:53pm    
Hurmm but sandeep do u know how to add autocomplete for each word user enter in the textfield? ;p

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900