开发者

Javascript update input element

I have quite a large IF statement which needs to update another form element depending on which scenarion only Its not working, By not working I mean its not updating the form element nor executing any more code in that statement.

My code is...

window.onload = function() {
new Dragdealer('magnifier', {
    steps: 10,
    snap: true,
callback: function(value) {
    if(value == 0) {
        alert('1');
        }开发者_JAVA技巧
    else if(value == 0.1111111111111111) {
        alert('2');
        }
    else if(value == 0.2222222222222222) {
        alert('3');
        }
    else if(value == 0.3333333333333333) {
        alert('4');
        }
    else if(value == 0.4444444444444444) {
        document.getElementById(coff_upd).value = '5';
        alert('5');
        }
    else if(value == 0.5555555555555556) {
        document.getElementById(coff_upd).value = '6';
        alert('6');
        }
    else if(value == 0.6666666666666666) {          
        document.getElementById(coff_upd).value = '7';
        alert('7');
        }
    else if(value == 0.7777777777777778) {
        document.getElementById(coff_upd).value = '8';
        alert('8');
        }
    else if(value == 0.8888888888888888) {
        document.getElementById(coff_upd).value = '9';
        alert('9');
        }
    else {
        document.getElementById(coff_upd).value = '10';
        alert ('10');
    }
    }
});
}

and the input...

    <input type="text" value="<?php echo $user_curr_coff;?>" name="coff_upd" id="coff_upd" />


Don't know if you cut and pasted your code but: document.getElementById(coff_upd).value = '5'; won't work as js is looking for a variable named coff_upd. You need to put quotes around it: document.getElementById("coff_upd").value = '5';

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜