| | |
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
![]() |
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:
- 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)
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
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.
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
![]() |
Similar Threads
- problem in displayin records on a form (VB.NET)
- speckly colors driving me up the wall!!!!!!! (Windows 95 / 98 / Me)
- problem with sending file over network using server/client (Java)
- Please HELP! 3 Problems with Form (PHP)
- problem in sending mail form web application (ASP.NET)
- how to load an image to a form (Visual Basic 4 / 5 / 6)
- [Bash] problem with script in sed command (Shell Scripting)
- Major problem with C++ compiler (C++)
- Internet Explorer Mess.. (Web Browsers)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: image gallery help
- Next Thread: How do you read radio buttons in XHTML
| Thread Tools | Search this Thread |
ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate array automatically browser bug calendar captchaformproblem cart checkbox child close codes createrange() cursor date debugger dependent disablefirebug dom dropdown editor element embed engine enter events explorer ext file firefox form forms frameworks getselection google gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe images internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jsp jump libcurl maps masterpage math media microsoft object onmouseoutdivproblem onreadystatechange parent paypal pdf php player position post programming progressbar prototype redirect regex runtime safari scale scriptlets scroll search security shopping size software sql text textarea unicode web website windowsxp wysiwyg \n






