A
alexandre damiron
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
....
editSelectFontOption1 = document.createElement("OPTION");
editSelectFontOption1.setAttribute("value", "Font", 0);
editSelectFontOption1Text = document.createTextNode("Font");
editSelectFontOption1.appendChild(editSelectFontOption1Text);
editSelectFontOption2 = document.createElement("OPTION");
editSelectFontOption2.setAttribute("value", "Arial", 0);
editSelectFontOption2Text = document.createTextNode("Arial");
editSelectFontOption2.appendChild(editSelectFontOption2Text);
editSelectFontOption3 = document.createElement("OPTION");
editSelectFontOption3.setAttribute("value", "Courier", 0);
editSelectFontOption3Text = document.createTextNode("Courier");
editSelectFontOption3.appendChild(editSelectFontOption3Text);
editSelectFontOption4 = document.createElement("OPTION");
editSelectFontOption4.setAttribute("value", "Times New Roman", 0);
editSelectFontOption4Text = document.createTextNode("Times New Roman");
editSelectFontOption4.appendChild(editSelectFontOption3Text);
....
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
....
editSelectFontOption1 = document.createElement("OPTION");
editSelectFontOption1.setAttribute("value", "Font", 0);
editSelectFontOption1Text = document.createTextNode("Font");
editSelectFontOption1.appendChild(editSelectFontOption1Text);
editSelectFontOption2 = document.createElement("OPTION");
editSelectFontOption2.setAttribute("value", "Arial", 0);
editSelectFontOption2Text = document.createTextNode("Arial");
editSelectFontOption2.appendChild(editSelectFontOption2Text);
editSelectFontOption3 = document.createElement("OPTION");
editSelectFontOption3.setAttribute("value", "Courier", 0);
editSelectFontOption3Text = document.createTextNode("Courier");
editSelectFontOption3.appendChild(editSelectFontOption3Text);
editSelectFontOption4 = document.createElement("OPTION");
editSelectFontOption4.setAttribute("value", "Times New Roman", 0);
editSelectFontOption4Text = document.createTextNode("Times New Roman");
editSelectFontOption4.appendChild(editSelectFontOption3Text);
....
It's not for laziness but readability and maintanability ;-)
Thanks, merci
Alexandre