Solved

Textarea - highlighting keywords

Posted on 2004-04-27
7
1,287 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
  • 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

770 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