Solved

Textarea - highlighting keywords

Posted on 2004-04-27
7
1,293 Views
Last Modified: 2008-03-03
hi all,

i am trying to hightlight certain words in <textarea>

so i have decided to change the color of those words(key words) in <textarea>

let me be more clear

i am trying to search the contents of <textarea> for some words and highlight them

the soln is very urgent

thanks in advance
0
Comment
Question by:Nandhini
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 1

Expert Comment

by:i_rajeevsingh
ID: 10936144
You cant change color of the words in text area but you can highlight them none the less but a range of words can be highlighted. You can use <p> tags to highlight if you wish
Regards
Rajeev
0
 
LVL 1

Author Comment

by:Nandhini
ID: 10936262
hi rajeev,
i need a sample program
0
 
LVL 1

Expert Comment

by:i_rajeevsingh
ID: 10937043
Check this
It took quite a time
---------------------------

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="JavaScript">
function  searchText(replaceText,byText)
{
var regEx = new RegExp(byText.value);
var regEx=regEx.compile(byText.value, "gi")
replaceText.innerHTML=(replaceText.innerHTML.replace(regEx,"<font color='#0000FF'>"+byText.value+"</font>"));
}
</script>

<body onLoad="document.form1.text1.select();">
<form action="" method="post" name="form1">
  <p> <strong>A quick brown fox jumps over a lazy dog</strong></p>
  <p>
    <input name="text1" type="text" id="text1" value="quick">
    <input type="button" name="Button" value="Search" onClick="searchText(textPara,text1);">
  </p>
</form>
</body>
</html>


Regards
Rajeev
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Assisted Solution

by:i_rajeevsingh
i_rajeevsingh earned 125 total points
ID: 10937053
Ooops  made a typo


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="JavaScript">
function  searchText(replaceText,byText)
{
var regEx = new RegExp(byText.value);
var regEx=regEx.compile(byText.value, "gi")
replaceText.innerHTML=(replaceText.innerHTML.replace(regEx,"<font color='#0000FF'>"+byText.value+"</font>"));
}
</script>

<body onLoad="document.form1.text1.select();">
<form action="" method="post" name="form1">
  <p id="textPara"> <strong>A quick brown fox jumps over a lazy dog</strong></p>
  <p>
    <input name="text1" type="text" id="text1" value="quick">
    <input type="button" name="Button" value="Search" onClick="searchText(textPara,text1);">
  </p>
</form>
</body>
</html>
0
 
LVL 1

Author Comment

by:Nandhini
ID: 10947294
hi rajeev!

ur program highlights the text in the document but not in textarea

but this is not my intention

any way thanks!

0
 
LVL 1

Accepted Solution

by:
i_rajeevsingh earned 125 total points
ID: 10947314
See you cant do that into textarea cause it is a textbox and if you will change color(using some CSS) then the whole of the color gets changed
Regards
Rajeev
0
 
LVL 1

Expert Comment

by:i_rajeevsingh
ID: 10947418
Hi  Nandhini

you have asked the same question twice
and have even requested to close one of the listed beneath
and the answer is same YOU CANT DO THAT

Q_20970138.html   Q_20970188.html

Rajeev
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
converting document.write() to innerHTML 7 53
DataTable column sorting incorrectly 2 22
modify change color of text 9 37
Javascript: Range object 16 14
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question