Save and recall a user-selected selection in the text area

I am using HTML, php, mySQL and jquery as tools. I currently have an area of ​​my site where users leave notes about their customer interactions. They can add tags to notes so that they can record which topics (tags) the notes cover. My goal is to take it one step further. I want to be able to record which topics contain certain text in a note. I want the client to be able to select the text in the text area to be saved as a link to a specific tag. I want to be able to recall all the text in their view that they have marked as relevant to the tag. This will be different from what I currently have for tagging the view as a whole.

For example, I could search my notes for the CONCERNS tag and instead of writing down all the notes tagged with the CONCERNS tag, which we are currently doing, I would like to raise a specific text in the note, has it been highlighted / selected as being CONCERNS, or at least a note with specific text highlighted.

I think I need to somehow store information about which character in the text the punch line starts and which character ends. In this way, the selection can be invoked and highlighted for the user as he views his notes and tags.

I've been looking for tools / plugins to help me complete this task for months with no luck. Anyone can offer any help / suggestions?

+3


source to share


1 answer


If the selected text is contained within an element INPUT

or TEXTAREA

, I use jQuery-caret to retrieve the selected text.
Using:



var input = $("#selector");
var range = input.caret();
var text = null;
// Get selected text
text = input.val().substr(range.start, range.end - 1);

      

0


source







All Articles