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
Post a Comment