i'm novice to this and can anybody say how to change CSS properties with javascript functions?
how can i change font-sizes/font styles using a combobox represented in a textarea?
[img]http://i.imgur.com/KH0om.jpg[/img]
if you can show me how events working..thank you

Recommended Answers

All 7 Replies

Member Avatar for stbuchok

It's much easier if you use the jQuery library.

<!doctype native>
<html>
<head>
</head>
<body>
Font Size: <select id=fontSize>
             <option>10pt</option>
             <option>12pt</option>
             <option>14pt</option>
           </select>

Font Family: <select id=fontFamily>
               <option>Arial</option>
               <option>Verdana</option>
               <option>Georgia</option>
             </select>

<div id=myDiv> some div </div>
<textarea id=myTextArea> some text content </textarea>

<script>

fontSize.onchange=fontFamily.onchange=setTarget;
setTarget=[myDiv,myTextArea/*etc*/];

function setTarget(x){
	for(x in setTarget)
		setTarget[x].style[this.id] = this.value;
	}
</script>
</body>
</html>

Thanks..but in this i can't see CSS and events are not working as you've coded.where is the wrong?

you are not meant "to see CSS" and the wrong is your lack of copy-paste skill probably [!]
the code works perfectly in all browsers including the ones that are to be invented in the future.
and
what do you mean "events are not working as you've coded"? how "else" are they supposed to work? the other way around?

sorry for my remissness friend.i checked in HTMLPad 2011 for previews.actually your code is working perfect on browsers..thank you very much.

sorry for my remissness friend.i checked in HTMLPad 2011 for previews.actually your code is working perfect on browsers..thank you very much.

So, what is your problem than?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.