Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-18-2010, 04:45 PM   PM User | #1
mrhudson87
New to the CF scene

 
Join Date: Mar 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
mrhudson87 is an unknown quantity at this point
Editable text color/size/typeface

hi,

im currently designing a website to go along with university dissertation.

i need to give the user of the site the ability to change the typeface, font size and font color.

i have a code that can currently change these features in one ID tag, however i need to be able to edit the text in multiple div tags.

my javascript looks like this:

Code:
<head>
<script language=javascript>
function changeStyle(element,property,value) {
document.getElementsById(element).style[property] = value;
}
</script>
</head>
and an example of my body looks like this:

Code:
<body>
<SELECT style="WIDTH: 100px" onchange="javascript:changeStyle('text', 'color', this.value);" size=1 name=fntcolour> 
<option style="background:#000000;color:white;" value="#000000">black</option>
<option style="background:#d60000;" value="#d60000">red</option>
<option style="background:#ec4c00;" value="#ec4c00">orange</option>
<option style="background:#eedb02;" value="#eedb02">yellow</option>
<option style="background:#00a652;" value="#00a652">green</option>
<option style="background:#00bff3;" value="#00bff3">blue</option>
<option style="background:#93268f;" value="#93268f">violet</option>
<option style="background:#FFFFFF;" value="#FFFFFF" selected>white</option>
</body>
any help would e greatly appreciated.

Thanks
John
mrhudson87 is offline   Reply With Quote
Old 03-19-2010, 04:43 AM   PM User | #2
A1ien51
Senior Coder

 
A1ien51's Avatar
 
Join Date: Jun 2002
Location: Between DC and Baltimore In a Cave
Posts: 2,717
Thanks: 1
Thanked 94 Times in 88 Posts
A1ien51 will become famous soon enough
Easier solution is to have a css file attachd and change the cs className for the body tag to adjust the new settings.

Eric
__________________
Tech Author [Ajax In Action, JavaScript: Visual Blueprint]
A1ien51 is offline   Reply With Quote
Reply

Bookmarks

Tags
class, color, div, font, size

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:24 AM.


Advertisement
Log in to turn off these ads.