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: koyel555 is an unknown quantity at this point 
Solved Threads: 0
koyel555 koyel555 is offline Offline
Newbie Poster

Change <div> text color & font without refreshing page

 
0
  #1
Aug 16th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 173
Reputation: FlashCreations is an unknown quantity at this point 
Solved Threads: 13
FlashCreations's Avatar
FlashCreations FlashCreations is offline Offline
Junior Poster

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

 
0
  #2
Aug 16th, 2009
You need to look into JavaScript and DOM. Give you DIV an id and then you can import the DIV as an object with:
  1. div = document.getElementById('div_id');
Then you can change the styles with:
  1. document.getElementById('div_id').color = '#999999';
See this page for help with DOM and JavaScript.
FlashCreations
(aka PhpMyCoder)

About Me | My Blog | Contact Me
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 811
Reputation: Airshow is on a distinguished road 
Solved Threads: 115
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark

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

 
0
  #3
Aug 16th, 2009
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.
50% of the solution lies in accurately describing the problem!
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 173
Reputation: FlashCreations is an unknown quantity at this point 
Solved Threads: 13
FlashCreations's Avatar
FlashCreations FlashCreations is offline Offline
Junior Poster

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

 
0
  #4
Aug 16th, 2009
Originally Posted by Airshow View Post
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...
FlashCreations
(aka PhpMyCoder)

About Me | My Blog | Contact Me
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 811
Reputation: Airshow is on a distinguished road 
Solved Threads: 115
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark

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

 
0
  #5
Aug 16th, 2009
Originally Posted by FlashCreations View Post
Wouldn't be the first time...
Same here. Easily done.

Airshow
50% of the solution lies in accurately describing the problem!
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 173
Reputation: FlashCreations is an unknown quantity at this point 
Solved Threads: 13
FlashCreations's Avatar
FlashCreations FlashCreations is offline Offline
Junior Poster

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

 
0
  #6
Aug 31st, 2009
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!
FlashCreations
(aka PhpMyCoder)

About Me | My Blog | Contact Me
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC