2

I am making application where i need to insert value which are double clicked.can any one suggest me how to insert a word in database after double click in any word in a paragraph.
Like http://www.thefreedictionary.com
In this Website after double click it search the meaning of that word, but i have to insert double clicked value in database.Please help me if any body have idea.
thanks in advance

2 Answers2

3

use AJAX preferably with jQuery. The process should work like this: dbclick->take data->initiate ajax request with POST to a PHP page->execute

Some sample code :

$('element').dblclick(function(){
  var data = //your handler here
  $.ajax({
     //code here
   });
});

Take a look at this: http://api.jquery.com/jQuery.ajax/

MayTheSchwartzBeWithYou
  • 1,111
  • 1
  • 13
  • 29
  • Check this also. Although I would recommend you search if it can be done with jquery. It will minimize your code size http://stackoverflow.com/questions/275761/how-to-get-selected-text-from-textbox-control-with-javascript – MayTheSchwartzBeWithYou Dec 11 '13 at 18:25
2

On page load, initiate one function which listen for double click. You can get jquery for it easily.

On click post selected text i.e. word through post(preferable) or get method to page which performs database insertion.

user123
  • 4,925
  • 15
  • 59
  • 113