...

View Full Version : Replace text in textarea



Matt_Helvey
07-07-2004, 08:26 PM
<html>
<head>
<title>test</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">

<script>
function replace(){
document.form.txt.replace(/&lt;script&gt;/, "<font color='red'>&lt;script&gt;</font>");
}
</script>
<body>
<form name="form">
<textarea name="txt" cols="20" rows="20" onKeyUp="javascript:replace();">test &lt;script&gt;</textarea>
</form>
</body>
</html>


------------------------------------------

You problably understand what I want to get out of this. :confused:

I want that when you eg. write "<script>" in the textarea it turns red (only the word script)

I'm not totally of the road with this code right? Please help... :o

Willy Duitt
07-07-2004, 08:55 PM
You can not do that. The textarea text color is all the same color.

Matt_Helvey
07-08-2004, 09:28 AM
ok
but it should be possible if i use editable div's right?

ex.

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
<style type="text/css">
DIV.editor {
width: 60%;
height: 100%;
font-family: Courier New;
font-size: 13px;
padding: 10px;
border: 1px solid #000000;
}
</style>

<div id="editor" class="editor" contentEditable></div>


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
but I can't put it together, please help...

jbot
07-08-2004, 11:30 AM
ok
but it should be possible if i use editable div's right?

yes, but you can't directly submit them to the server. you'll have to copy their contents, plus any extra formatting markup to a hidden textarea, before submission.

Matt_Helvey
07-10-2004, 07:03 PM
what?

I only want it to be an editor with. No submissions or whatever you're talking about. Can someone givé a code example???

Sorry but this is really beginning to get on my nerves



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum