943,671 Members | Top Members by Rank

Ad:
Aug 16th, 2009
0

Change <div> text color & font without refreshing page

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
koyel555 is offline Offline
29 posts
since Aug 2009
Aug 16th, 2009
0

Re: Change <div> text color & font without refreshing page

You need to look into JavaScript and DOM. Give you DIV an id and then you can import the DIV as an object with:
JavaScript Syntax (Toggle Plain Text)
  1. div = document.getElementById('div_id');
Then you can change the styles with:
JavaScript Syntax (Toggle Plain Text)
  1. document.getElementById('div_id').color = '#999999';
See this page for help with DOM and JavaScript.
Reputation Points: 47
Solved Threads: 47
Posting Whiz
FlashCreations is offline Offline
393 posts
since Sep 2008
Aug 16th, 2009
0

Re: Change <div> text color & font without refreshing page

But not forgetting ".style"
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. document.getElementById('div_id').style.color = '#999999';
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
Last edited by Airshow; Aug 16th, 2009 at 9:45 pm.
Sponsor
Reputation Points: 302
Solved Threads: 358
WiFi Lounge Lizard
Airshow is offline Offline
2,524 posts
since Apr 2009
Aug 16th, 2009
0

Re: Change <div> text color & font without refreshing page

Click to Expand / Collapse  Quote originally posted by Airshow ...
But not forgetting ".style"
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. document.getElementById('div_id').style.color = '#999999';
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
Ahh....yes! I clumsily forgot to place .style before the .color or any other property. Wouldn't be the first time...
Reputation Points: 47
Solved Threads: 47
Posting Whiz
FlashCreations is offline Offline
393 posts
since Sep 2008
Aug 16th, 2009
0

Re: Change <div> text color & font without refreshing page

Wouldn't be the first time...
Same here. Easily done.

Airshow
Sponsor
Reputation Points: 302
Solved Threads: 358
WiFi Lounge Lizard
Airshow is offline Offline
2,524 posts
since Apr 2009
Aug 31st, 2009
0

Re: Change <div> text color & font without refreshing page

Very easily done!
Anyhow, if all of your problems have been solved and all questions answers I ask that you mark this thread as solved!! Thanks!
Reputation Points: 47
Solved Threads: 47
Posting Whiz
FlashCreations is offline Offline
393 posts
since Sep 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: add to div
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: for label and design output





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC