0

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');
        }
    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" />

1 Answer 1

4

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';

Sign up to request clarification or add additional context in comments.

1 Comment

If you had opened up JS console in FF Ctrl+Shift+J it would of given you a line number and a error message.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.