When should use id?
I am wondering when I can use id instead of variable. For example,
var control=new AW.UI.Input;
control.setId("id");
document.write(control);//works
document.write(id);//not work
document.write(document.getElementById(id));//not work
document.write(control) works, but document.write(id) or document.write(document.getElementById(id)) don't work.
Actually, I need to dynamically create some controls and set them a meaningly name as refrences. For example,
var c=new Array();
for (var i=0; i<100; i++){c[i]=new AW.UI.Input;}
c[0].setId("Apple");
c[1].setId("Bear");
c[2].setId("Chart");
......
Apple.setControlText("red");
Bear.setControlText("black");
Chart.setControlText("Color");
Could you give me an idea when should I use varable and when should I use ID?
Thanks,
var control=new AW.UI.Input;
control.setId("id");
document.write(control);//works
document.write(id);//not work
document.write(document.getElementById(id));//not work
document.write(control) works, but document.write(id) or document.write(document.getElementById(id)) don't work.
Actually, I need to dynamically create some controls and set them a meaningly name as refrences. For example,
var c=new Array();
for (var i=0; i<100; i++){c[i]=new AW.UI.Input;}
c[0].setId("Apple");
c[1].setId("Bear");
c[2].setId("Chart");
......
Apple.setControlText("red");
Bear.setControlText("black");
Chart.setControlText("Color");
Could you give me an idea when should I use varable and when should I use ID?
Thanks,
April 27,