Solved

Textarea - highlighting keywords

Posted on 2004-04-27
7
1,296 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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…

705 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