javascript - Autocomplete - two fields -


i'm trying create page fields, use autocomplete function. first field - "ana" works fine. second fails. don't see errors in console. prompt doesn't appear. here snippet:

<script src="/inc/jquery-1.8.3.js"></script> <script src="/inc/jquery-ui.js"></script> <link href="/inc/jquery-ui.css" rel="stylesheet" type="text/css"/>  <table> <tr> <td>ticker:</td><td><input type="text" name="ana" /></td> </tr> <tr> <td>cmp:   </td><td><input type="text" name="sou" /></td> </tr> </table> <div id="result" style="margin-top:25px;"></div> <script language="javascript"> $(document).ready(function() {     ana = [ <% getana %>];     $("input[name='ana']").autocomplete({ source: ana });      sou = [ <% getsou %>];     $("input[name='sou']").autocomplete({ source: sou});  });  </script> 

i' cutting getana , getsou. these works. here js/html source code:

<script language="javascript"> $(document).ready(function() {     ana = [ "aar  edw"];     $("input[name='ana']").autocomplete({ source: ana });      sou = [ "a&a equity research"];     $("input[name='sou']").autocomplete({ source: sou});  });  </script> 

try this

    $(document).ready(function () {         var ana = array();          $.ajax({             type: "post",             url: "pagename.aspx/getana", //getana must public static web method             data: "{}",             contenttype: "application/json; charset=utf-8",             datatype: "json",             async: false,             success: function (data) {                 $.map(data.d, function (item) {                     ana.push(item.name);                 })             }         });         $("input[name='ana']").autocomplete({ source: ana });          var sou = array();         $.ajax({             type: "post",             url: "pagename.aspx/getsou", //getsou must public static web method             data: "{}",             contenttype: "application/json; charset=utf-8",             datatype: "json",             async: false,             success: function (data) {                 $.map(data.d, function (item) {                     ana.push(item.name);                 })             }         });         $("input[name='sou']").autocomplete({ source: sou });      }); 

in code behind

    [webmethod]     public static list<valuepair> getana()//example method same method getsou     {         list<valuepair> lstvaluepair = new list<valuepair>();        // resumefrombal objresumefrombal = new resumefrombal();        // resumefrom objresumefrom = new resumefrom();         dataset ds = new dataset();//use code dynamic data         // ds = objresumefrombal.getana();          if (ds.tables.count > 0)         {              foreach (datarow item in ds.tables[0].rows)             {                 lstvaluepair.add(new valuepair() { name = item["resumefromname"].tostring(), value = item["resumefromid"].tostring() });             }          }         return lstvaluepair;      }     public class valuepair     {         public string name { get; set; }         public string value { get; set; }     } 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -