English 中文(简体)
Highlight text as typed that matches array from recordset. Create qTip when hovering over highlighted text
原标题:

I know generally how to approach this, but my jQuery skills aren t quite up to par. Any help would be much appreciated! Here s what I m trying to do:

1) I have an existing textarea where user can enter text

2) I have an existing database table with string pairs (string1, string2)

3) I d like to be able to highlight all strings (maybe applying a <span class="highlight"></span> with background color or italics in my css) as the user types them into the textarea that match any of the string1 results from the database (the strings could be one word or multiple word phrases, but would not be portions of a word). When the user hovers over the highlighted strings, the corresponding string2 appears in a basic qTip2.

4) If the user changed the text, the highlighting and qTip would go away if it no longer matched one of the string1 rows.

5) I envision creating a json array using PHP json_encode from the mysql_fetch_assoc recordset each time the page is called that would contain the string1 and string2 data since the string1 and string2 data is dynamic.

最佳回答

There s a bit of complexity in what you re asking, but as a starting point, you may want to look at Craig s Google translate demo on the qTip site that does a little bit of what you re asking. When the user highlights a word, it does a Google translation on the selected item and displays the translation in a qTip:

http://www.craigsworks.com/projects/qtip2/demos/#translate

问题回答

暂无回答




相关问题
JQuery/MVC Search Issue

I have inherited a piece of work where the entry screen shows a summary of 20 calculated variables. E.g. Var A (250), Var B (79). Clicking on any of these links takes the user to a view with a ...

jQuery quicksearch plug-in tinkering with JSON

I ve implemented the quicksearch plugin by Rik Lomas and I love it for an application in a custom CMS I m building. I was wondering though, since I m going to have a bizillion items in the table if ...

JSON with classes?

Is there a standardized way to store classes in JSON, and then converting them back into classes again from a string? For example, I might have an array of objects of type Questions. I d like to ...

PHP json_decode question

i m trying to use json_decode to combine a few json objects and then re-encode it. my json looks like: { "core": { "segment": [ { "id": 7, "...

Converting JSON data to Java object

I want to be able to access properties from a JSON string within my Java action method. The string is available by simply saying myJsonString = object.getJson(). Below is an example of what the string ...

热门标签