| | |
Change <div> text color & font without refreshing page
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Aug 2009
Posts: 12
Reputation:
Solved Threads: 0
I need quick help, its urgent for my job, pls help me.
I need to change the font color, font size & font face of some text assigned in a div. To do so I have a form select option menu at the top, adn below the menu three's 3/4 divs with some text. I need to change text properties of the div from select menu, and the page must not refresh. Its actually a little version of text editor.
I'll be glad if someone solves it ASAP.
I need to change the font color, font size & font face of some text assigned in a div. To do so I have a form select option menu at the top, adn below the menu three's 3/4 divs with some text. I need to change text properties of the div from select menu, and the page must not refresh. Its actually a little version of text editor.
I'll be glad if someone solves it ASAP.
You need to look into JavaScript and DOM. Give you DIV an id and then you can import the DIV as an object with:
Then you can change the styles with:
See this page for help with DOM and JavaScript.
JavaScript Syntax (Toggle Plain Text)
div = document.getElementById('div_id');
JavaScript Syntax (Toggle Plain Text)
document.getElementById('div_id').color = '#999999';
But not forgetting ".style"
But I'm sure FlashCreations knows that really.
Koyel555, I think you might need to give your controls some more thought. You say there are several divs and several factors (font, color, size) but you only mention one control - a select menu.
It depends exactly what you want but you may need one menu per div, and possibly one menu per factor per div.
Another way of diing it would be to have a single set of controls (one per factor) and a way to signify an "active" div on which they operate - one div at a time.
It is certainly hard to see how a single select menu would offer adequate control.
Airshow
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
document.getElementById('div_id').style.color = '#999999';
Koyel555, I think you might need to give your controls some more thought. You say there are several divs and several factors (font, color, size) but you only mention one control - a select menu.
It depends exactly what you want but you may need one menu per div, and possibly one menu per factor per div.
Another way of diing it would be to have a single set of controls (one per factor) and a way to signify an "active" div on which they operate - one div at a time.
It is certainly hard to see how a single select menu would offer adequate control.
Airshow
Last edited by Airshow; Aug 16th, 2009 at 9:45 pm.
50% of the solution lies in accurately describing the problem!
•
•
•
•
But not forgetting ".style"
But I'm sure FlashCreations knows that really.JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
document.getElementById('div_id').style.color = '#999999';
Koyel555, I think you might need to give your controls some more thought. You say there are several divs and several factors (font, color, size) but you only mention one control - a select menu.
It depends exactly what you want but you may need one menu per div, and possibly one menu per factor per div.
Another way of diing it would be to have a single set of controls (one per factor) and a way to signify an "active" div on which they operate - one div at a time.
It is certainly hard to see how a single select menu would offer adequate control.
Airshow
Wouldn't be the first time...
![]() |
Similar Threads
- Change text color using visual c++ (C++)
- JTextArea & Font Color (Java)
- Custom page to login to Yahoo, Gmail, MSN etc (JavaScript / DHTML / AJAX)
- Insert to DB & View Results on Different Page (ASP.NET)
- IE quirk-no images showing on my index page (HTML and CSS)
- Cross page posting confusion (ASP.NET)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: add to div
- Next Thread: for label and design output
| 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





