javascript - jscript to run at window.onload AND item.onchange -
i'm using jscript load string in several elements of array, display useful element in html.
there's pulldown menu causes string change. so, need function re-run when happens.
i have been able display element using window.onload
and, have been able display element after pulldown menu has been changed.
but, can't seem display element window.onload , subsequently after item.onchage
if has suggestions, i'd grateful.
here code works window.onload
window.onload = function() { var selectedoptionid = jquery('select').val(); var optionpartnumber = jquery('input[name="optid_' + selectedoptionid + '"]').val(); //loads string in array , returns 2nd element var optionpartnumber = optionpartnumber.split(".")[1]; document.getelementbyid("masnum").innerhtml=optionpartnumber; }
here code works pulldown.onchange
jquery(function(){ jquery('.dropdownimage-format select').on('change', function(){ var selectedoptionid = jquery('select').val(); var optionpartnumber = jquery('input[name="optid_' + selectedoptionid + '"]').val(); var optionpartnumber = optionpartnumber.split(".")[1]; document.getelementbyid("masnum").innerhtml=optionpartnumber; });
in both cases, element displayed in html by
<a id="masnum">
Comments
Post a Comment