0

I'm trying to take flexible arguments in javascript to manipulate color with the eyecon colorpicker (www.eyecon.ro/colorpicker/)

But when I try to change color the page hangs, is it getting stuck in the arguments.length loop?

the html is:

<div class="colorSelector" id="colorSelector3"><div style="background-color: #0000ff"></div></div>

and the jquery/javascript is:

$('#colorSelector3').click(function(){
colorPickDynamic('#colorSelector3','h1','color');
});


function colorPickDynamic(cp){

var i;
var j;

for (x=0, i = 1, j = 2; j < arguments.length; i+2, j+2, x++) {

var tag = [];
var colorProperty = [];
tag[x]=arguments[i];
colorProperty[x]=arguments[j];
}

$(cp).ColorPicker({
    color: '#0000ff',
    onShow: function (colpkr) {
        $(colpkr).fadeIn(500);
        return false;
    },
    onHide: function (colpkr) {
        $(colpkr).fadeOut(500);
        return false;
    },
    onChange: function (hsb, hex, rgb) {

                            $(tag[0]).css(colorProperty[0], '#' + hex);

        $(cp + ' div').css('backgroundColor', '#' + hex);
    }
});
}

any help would be amazing! thanks

3
  • can you define more explicitly what you want the method signature of colorPickDynamic to be. In other words, what should each argument, or list of arguments represent? Commented Sep 10, 2012 at 17:18
  • arguments[0], arguments[1]... arguments.length is also there Commented Sep 10, 2012 at 17:19
  • note that "arguments" is not a real array, just a work-around if i may Commented Sep 10, 2012 at 17:20

1 Answer 1

6

You have an infinite loop, you are never incremementing j.

j+2 should be j+=2, i+2 should be i+=2

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

2 Comments

how silly of me, switching from c to javascript ive become much less attentive! ill try this when i get back to the computer, thanks!
hmm it is still stuck in this loop with j+=2 and i+=2? is the logic wrong?

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.