javascript - JS/HTML onChange -


with similar question. :)

<input type="text" name="npcolor" id="npcolor" size="9" maxlength="9" value="<?=$userinfo->npcolor?>" onchange="change_npcolor()" readonly /> <input type="text" id="np_sample" size="2" value="" readonly style="background-color:<?=$userinfo->npcolor?>" /> <input type="button" onclick="pickerpopup202('npcolor','np_sample');" value="change" /> 

function pickerpopup202 changing npcolor, when npcolor changed don't call change_npcolor(). when put button call change_npcolor works. tried also:

document.getelementbyid("npcolor").onchange='change_npcolor()'; 

without success.

p.s. js changes npcolor (pickerpopup202) isnt mine, , code @ 1 line, cant mod it.

when change value dynamically, onchange event doen't fire. need call change_npcolor() method yourself. call document.getelementbyid("npcolor").onchange(). (this less efficient, more flexible when event handler may change eventually.)

you cannot change event listener adding string javascript code onchange property. can this, however:

document.getelementbyid("npcolor").onchange = function(){    change_npcolor(); } 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -