function new_select(id, obj) { array_s = obj; array_int = document.getElementById(id); for(i = 1; i <= array_s.length; i++) { var array_value = array_s[i][1]; var array_text = array_s[i][0]; } array_int.innerHTML += '<b>'+array_title+'</b>'+array_value+' '+array_text; } 

It is necessary that the code:

 array_int.innerHTML += '<b>'+array_title+'</b>'+array_value+' '+array_text; 

worked outside the loop . How to do?

  • And now it does not work? And why is it necessary outside? - Chad
  • declare variables outside the loop - Specter
  • @Spectre, asd = array_value; I declare outside the loop, further alert (sd) and does not work. - ModaL
  • Well, outside the loop, the latest values ​​of array_s will be available. If asd is not available, then maybe there is no value? Check array_s. - forum3
  • @ forum3, it works successfully in the loop, but not in the loop ... - ModaL

1 answer 1

some street magic

 function new_select(id, obj) { array_s = obj; var array_value =''; var array_text =''; array_int = document.getElementById(id); for(i = 1; i <= array_s.length; i++) { array_value += array_s[i][1]; array_text += array_s[i][0]; } array_int.innerHTML += '<b>'+array_title+'</b>'+array_value+' '+array_text; }