| | |
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: 29
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
Views: 1407 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxexample ajaxjspservlets api blackjack browser bug captchaformproblem checkbox child class close cookies createrange() cursor date debugger dependent developer disablefirebug dom dropdown editor element embed engine events explorer ext file flash form forms game gears getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe images internet java javascript javascripthelp2020 jquery jsf jsfile jump libcurl maps margin math matrixcaptcha media mp3 mysql object onerror onmouseoutdivproblem onreadystatechange parent passing paypal pdf php player position post programming progressbar rated runtime safari scriptlets scroll search security session shopping size software solutions star stars stretch synchronous tweet unicode web webkit webservice window wysiwyg \n





