jquery - Issue in iterating the array in javascript -


i have array named a[] contains city_id , city name

then doing edit , details such cityid,countryid,etc

and save in var b= cityid

now cityname , appending field textbox

i iterating array thru each function

 function f1() {      jquery(a). each(function(m) {          if(this.city_id(from array a) == cityid)              if(c== "") {                  c += this.cityname;              } else {                  c += ","+ this.cityname;              }      });   } 

c global var problem on click of edit c bombay,delhi,puna

but again next time if click on radio button fetch details gets appended bombay,delhi,puna,chennai instead of clearing first one.

try this.. here each obj in array.

$.each( a, function( i, val ) {   if(i.city_id== cityid)              if(c== "") {                  c += this.cityname;              } else {                  c += ","+ this.cityname;              } }); 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -