Appending Javascript Array Values to the DOJO div

你说的曾经没有我的故事 提交于 2020-01-11 13:48:13

问题


I have a Array of Values as shown above .

myarray2.push("10-FEB-11");
myarray2.push("11-FEB-11");
myarray2.push("12-FEB-11");
myarray2.push("13-FEB-11");
myarray2.push("14-FEB-11");

I want to have these Values inside the div hrXAxisSlider as shown (Currently its hardcoded , but is that possible )

  <div id="hrXAxisSlider"
  dojoType="dojox.form.HorizontalRangeSlider">


   <ol dojoType="dijit.form.HorizontalRuleLabels" >
     <li>10-FEB-11</li><li>11-FEB-11</li><li>12-FEB-11</li><li>13-FEB-11</li><li>14-FEB-11</li>
   </ol>


</div>

回答1:


You can accomplish this with a simple javascript for loop:

var ol = document.getElementById('hrXAxisSlider')
                 .getElementsByTagName('ol')[0],
    ma2l = myarray2.length,
    i, 
    htmlFrag = '';

for (i = 0; i < ma2l; i++) {
    htmlFrag += '<li>' + myarray2[i] + '</li>';
}

ol.innerHTML = htmlFrag;

See example →



来源:https://stackoverflow.com/questions/5450913/appending-javascript-array-values-to-the-dojo-div

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!