textbox - AJAX options box when clicking on a word? -


is possible ? have phrase on textbox:

"i went home"

then when click "home" options box shows like:

"i entered home"          |garden|          | motel|          |______| 

sorry ugly way show it, couldn't think better lol

<!doctype html> <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(function(){     $("#fieldname").focus(function(){         var el = $(this);         var coords = el.offset();         var div = $("<div>").addclass("dropdown").html("<span>garden</span><span>motel</span>").css({"top":coords.top+18+"px","left":coords.left+45+"px"});         el.after(div);         $(".dropdown span").click(function(){             var newtext = "i entered " + $(this).text();             $("#fieldname").val(newtext);             $("div.dropdown").remove();         });     }); }); </script> <style>     .text {width:120px;}     .dropdown {width:75px; text-align:right; position:absolute; padding:2px; background:#eee; border:1px solid #aaa;}     .dropdown span {display:block; cursor:pointer;} </style> </head> <body> <input type="text" class="text" name="fieldname" id="fieldname" value="i entered home" /> </body> </html> 

you'll need copy of jquery (or point google's cdn of it) work. example's pretty primitive, it'll want go.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -