javascript - JQuery to add list items -


i have autocomplete input field using jquery. following jquery return list

$(function () {     var list = list[<%=additional.count%>];     <% (var = 0; < additional.count; i++)     { %>         list[<%=i%>] = <%=additional[i].text %>;     <% } %>     var availabletags = list;      $("#scheme_textbox").autocomplete({         source: availabletags,         select: function (event, ui)         {             selectedorigoscheme();         }     }); }); 

the list generated in code behind shown below

list<ajbg.servicecontracts.messages.thirdpartyapis.origo.getstaticcedingschemes.cedingscheme> origocedingschemes = target.getstaticcedingschemes(request).cedingschemes;             list<selectlistitem> listitems = new list<selectlistitem>();             foreach (ajbg.servicecontracts.messages.thirdpartyapis.origo.getstaticcedingschemes.cedingscheme origocedingscheme in origocedingschemes)             {                 listitems.add(new selectlistitem() { text = origocedingscheme.schemename, value = origocedingscheme.counterpartyschemeorigoid.tostring(), selected = false });             }             var selectitemlist = listitems list<selectlistitem>; 

my view

<%=html.textbox("scheme_textbox", "", new { style = "width:98%;", placeholder= "type search...", onblur="selectedorigoscheme(this);" })%> 

but when run code following jquery error

.....\n\nscript1004: expected ';'

below of results returns: $(function () { var list = list[2103];

        list[0] = **self invested personal pension**;          list[1] = wealth **at work ltd**;          list[2] = deloitte **pension plan cimp**;          list[3] = **carey pension scheme**;          list[4] = sippdeal **e**-sipp;          list[5] = aegon;          list[6] = aegon;          list[7] = alliance **trust**;          list[8] = alliance **trust**;          list[9] = ashby **london sipp**;          list[10] = ashcourt **rowan**;          list[11] = aviva;          list[12] = aviva;          list[13] = axa **wealth personal pension plan**;          list[14] = axa **winterthur**;          list[15] = bank **of** ireland sipp;          list[16] = barclays stockbrokers sipp;          list[17] = brewin dolphin sipp;          list[18] = capita sipp;          list[19] = city trustees;          list[20] = clerical medical sipp;          list[21] = clerical medical stakeholder plan;          list[22] = cofunds pension account;          list[23] = dentons sipp c g drennen;          list[24] = european wealth management scheme stockmarket sipp;          list[25] = fidelity sipp;          list[26] = friends life;          list[27] = friends life (provident); 

note: bold wording list fails on.

i tried doing list[<%=i%>] = "<%=additional[i].text %>" caused following error

javascript runtime error: unable property '2103' of undefined or null reference

the 2103 how many result returned in list in code behind. easy i've spent last 3hrs trying resolve various people helping , can not solve issue.

list[0] = **self

this text (literal) , should wrapped in quotes within javascript. either singles or doubles acceptable.

list[0] = 'my message string (literal)'

to honest looks want using javascript view model framework ideally. looks me doing hard way.

see angular, knockout backbone etc.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -