Jump to content

Button update?


max_peed

Recommended Posts

Hi! Im trying to make a button update the backgroundcolor of a <div>, with the colorvalue of a text input field. It kindof works in FF when i press F5 but not w the button, and IE and Chrome wont work.I think i need to get the button to refresh, but i dont know how to... my code is

var button = document.getElementById("bCol");var inputten = document.getElementById("iCol").value;var diven = document.getElementById("diven"); if(button.addEventListener){button.addEventListener("click", ImgPicker.changeCol(inputten), false);} else{button.attachEvent("onclick", ImgPicker.changeCol(inputten));}

and in ImgPicker, this one will search through the CSSfile for my diven-class

changeCol: function(color){for(var i = 0; i < document.styleSheets.length; i++){for(var x = 0; x < document.styleSheets[i].cssRules.length; x++){if(document.styleSheets[i].cssRules[x].selectorText == ".diven"){document.styleSheets[i].cssRules[x].style.cssText = "background-color: " + color;refresh;}}}}

Please, help?

Edited by max_peed
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...