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
Solved

Textarea - highlighting keywords

Posted on 2004-04-27
7
1,291 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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
How can I repeat this modal box over and over again...? 2 24
Else condition 9 23
how can i get 4 nd 5 ? 3 31
Head to not include on scroll 4 23
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

860 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