문제

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>
도움이 되었습니까?

해결책

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 →

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top