WebDeveloper
08-11-2008, 11:05 PM
I'm Building a HTML Page Builder . I'm Trying To Create a Function To Bold a text in a textarae . after thinking i came up with this :
<html>
<head>
<script>
function BoldMyText ()
{
TextEditor.Text.style.cssText = "font-weight : bold"
}
</script>
</head>
<body>
<form name = "TextEditor">
<textarea name = "Text"></textarea>
<input type = "button" value = "Bold It" onClick = "BoldMyText ()">
</form>
</body>
</html>
But The Problem With This Script is that is the function is bolding the hole text of the textarea . and when i created an UnBolding function it unbolded the hole text in the textarea .
The Problem Is How To Bold a Selected Text In The Textarea ???
<html>
<head>
<script>
function BoldMyText ()
{
TextEditor.Text.style.cssText = "font-weight : bold"
}
</script>
</head>
<body>
<form name = "TextEditor">
<textarea name = "Text"></textarea>
<input type = "button" value = "Bold It" onClick = "BoldMyText ()">
</form>
</body>
</html>
But The Problem With This Script is that is the function is bolding the hole text of the textarea . and when i created an UnBolding function it unbolded the hole text in the textarea .
The Problem Is How To Bold a Selected Text In The Textarea ???