0

Hello,

Well I've got a bunch of Textboxes with color hex codes inside (#cccccc). Now in an IFrame on the same page I want to use these colors.
I couldn't find a solution yet, can somebody please help me.

Thanks in advance.

2
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by MidiMagic
0

In javascript:
- You have to read the value from the text box.
- You have to make a string with the #rrggbb value in it.
- You have to assign the value so created to the style attribute needed.

Remember that the hyphenated form does not exist in javascript. So:

"background-color" in css, becomes
"backgroundColor" in JavaScript.

The following is an example of the form prgrss with object os3, and an array of color codes colox:

document.forms.prgrss.os3.style.backgroundColor = colox[cox];
0

Well lets say I have something like this:

<body bgcolor="doument.form.field.value;">

Why doesent it work?

0

What you wrote doesn't work because the html is rendered before those values exist.

HTML is a passive language. It renders once, then quits.

Also, the variable you are trying to read is not available to the body tag. A tag's attributes are defined only inside that tag.

And the syntax "document.form.field.value;" is JavaScript syntax, not html or css syntax.

And it works better if you can spell "document".

Finally, the bgcolor attribute is deprecated. It will not be supported in future web language.

You must use JavaScript (or a server-side script) to do any dynamic (changeable) content.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.