Did anyone tried dynamic variable naming in Js, like the ${$varname}
feature of PHP ? It would easier a long DOM generation, for example to
place such a code portion into a loop
....
editSelectFontO ption1 = document.create Element("OPTION ");
editSelectFontO ption1.setAttri bute("value", "Font", 0);
editSelectFontO ption1Text = document.create TextNode("Font" );
editSelectFontO ption1.appendCh ild(editSelectF ontOption1Text) ;
editSelectFontO ption2 = document.create Element("OPTION ");
editSelectFontO ption2.setAttri bute("value", "Arial", 0);
editSelectFontO ption2Text = document.create TextNode("Arial ");
editSelectFontO ption2.appendCh ild(editSelectF ontOption2Text) ;
editSelectFontO ption3 = document.create Element("OPTION ");
editSelectFontO ption3.setAttri bute("value", "Courier", 0);
editSelectFontO ption3Text = document.create TextNode("Couri er");
editSelectFontO ption3.appendCh ild(editSelectF ontOption3Text) ;
editSelectFontO ption4 = document.create Element("OPTION ");
editSelectFontO ption4.setAttri bute("value", "Times New Roman", 0);
editSelectFontO ption4Text = document.create TextNode("Times New Roman");
editSelectFontO ption4.appendCh ild(editSelectF ontOption3Text) ;
....
It's not for laziness but readability and maintanability ;-)
Thanks, merci
Alexandre
feature of PHP ? It would easier a long DOM generation, for example to
place such a code portion into a loop
....
editSelectFontO ption1 = document.create Element("OPTION ");
editSelectFontO ption1.setAttri bute("value", "Font", 0);
editSelectFontO ption1Text = document.create TextNode("Font" );
editSelectFontO ption1.appendCh ild(editSelectF ontOption1Text) ;
editSelectFontO ption2 = document.create Element("OPTION ");
editSelectFontO ption2.setAttri bute("value", "Arial", 0);
editSelectFontO ption2Text = document.create TextNode("Arial ");
editSelectFontO ption2.appendCh ild(editSelectF ontOption2Text) ;
editSelectFontO ption3 = document.create Element("OPTION ");
editSelectFontO ption3.setAttri bute("value", "Courier", 0);
editSelectFontO ption3Text = document.create TextNode("Couri er");
editSelectFontO ption3.appendCh ild(editSelectF ontOption3Text) ;
editSelectFontO ption4 = document.create Element("OPTION ");
editSelectFontO ption4.setAttri bute("value", "Times New Roman", 0);
editSelectFontO ption4Text = document.create TextNode("Times New Roman");
editSelectFontO ption4.appendCh ild(editSelectF ontOption3Text) ;
....
It's not for laziness but readability and maintanability ;-)
Thanks, merci
Alexandre
Comment