Solved

Textarea - highlighting keywords

Posted on 2004-04-27
7
1,275 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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.
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now