Problem with applying colors from form

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Aug 2007
Posts: 2
Reputation: sted is an unknown quantity at this point 
Solved Threads: 0
sted sted is offline Offline
Newbie Poster

Problem with applying colors from form

 
0
  #1
Aug 8th, 2007
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.
Last edited by sted; Aug 8th, 2007 at 6:14 pm.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 164
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: Problem with applying colors from form

 
0
  #2
Aug 8th, 2007
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:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. document.forms.prgrss.os3.style.backgroundColor = colox[cox];
Last edited by MidiMagic; Aug 8th, 2007 at 7:52 pm.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 2
Reputation: sted is an unknown quantity at this point 
Solved Threads: 0
sted sted is offline Offline
Newbie Poster

Re: Problem with applying colors from form

 
0
  #3
Aug 8th, 2007
Well lets say I have something like this:

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

Why doesent it work?
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 164
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: Problem with applying colors from form

 
0
  #4
Aug 8th, 2007
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.
Last edited by MidiMagic; Aug 8th, 2007 at 9:47 pm.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC