• Post Reply Bookmark Topic Watch Topic
  • New Topic

Highlight search terms in inputtextarea  RSS feed

 
Muneeswaran Balasubramanian
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all,

I have one inputtext,commandbutton and inputtextarea.
I want to search the text which is given in inputtext and highlight the same searchtexts in the input textarea.
is there any way to achieve this?
 
Tim Holloway
Bartender
Posts: 18715
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't do that in an inputtextarea control, because it's not designed for text formatting. The closest you could come would be to use JavaScript to select the text of interest - which would visually highlight. But I don't think you can select more than one sequence of characters on a web page.

For server-based display-only highlighting you could create a text display zone such as a single-column/single-row panelGrid (or use brute force and an HTML div element), then outputText using the escape-disable feature, inserting highlighting tags.

For highlighting of read/write text, you could use one of the formatted tag extensions such as the RichFaces rich text editor. Although trying to edit highlighted input text can confuse users.
 
Pradeep Katipamula
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Go through http://plugins.jquery.com/project/jCaret

Here is an extract from the pages.



Hope this helps and please note this is purely javascript and nothing to do with JSF

Pradeep
 
Muneeswaran Balasubramanian
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pradeep,

This was very helpful to me.But when i try the above code it found out and highlight the term when it will appear at first time only.I have make some changes and resolve the above problem.But in the code,I can't move the scroll to the highlighted search term.
Is there anyway to achieve this?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!