I know this must be simple because I cannot find a reference to it. I would like to use javascript to load the background-color value of a table row into a css file. The background will vary depending on which menu option is chosen. To hopefully clear this up, the row has a css class and I would like to populate that with a color. Thanks in advance.
Bob

Recommended Answers

All 4 Replies

why not simply change the class of the row instead?

actually that is the way it was to start...however, client would like to have different colors based up which menu option is selected. Thus, rather than having different lines of code, only need to change it via the js....hope that was clear.....Can this be done?
thanks for the reply.

actually that is the way it was to start...however, client would like to have different colors based up which menu option is selected. Thus, rather than having different lines of code, only need to change it via the js....hope that was clear.....Can this be done?
thanks for the reply.

no that's not true, you will be forced to have more lines of code if you try that manipulation through javascript, and on top of it all, you will be having to much problems with browsers and moreover this aproach is not reliable. Changing style declarations dynamically will give you more headache than you can think off.
I also don't think that there are clients with such demands, because if your client understands things like these than he must be your coding teacher not your client.

ok will take your advice.....just seemed so easy to change with what i thougt would be one line of code.....kudos to you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.