javascript - Output to multiple divs using getElementsByClassName? -


i want output multiple elements using javascript. following example may show want.

<select id="leave" onchange="leavechange()">   <option value="">select</option>   <option value="150">ems</option>   <option value="350">dhl</option>   <option value="200">ups</option>   <option value="75">ethiopia postal</option> </select> <script> function leavechange() {     if (document.getelementbyid("leave").value == document.getelementbyid("leave").value){         document.getelementsbyclassname("item_shipping")[0].innerhtml = document.getelementbyid("leave").value;     }          else{         document.getelementbyid("item_shipping").innerhtml = 0;     }         }  </script> <div class="item_shipping"></div> //this getting value <div class="item_shipping"></div> //this empty want same value? 

the first div show result second 1 empty. how update both?

function leavechange() {         var leavevalue = document.getelementbyid("leave").value;         var shippingitems = document.getelementsbyclassname("item_shipping");          (var = 0; < shippingitems.length; i++) {             if (leavevalue == leavevalue) // ??                 shippingitems[i].innerhtml = leavevalue;             else                 shippingitems[i].innerhtml = 0;         }     } 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -