Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/10/2012, 15:15
Requenaeo
 
Fecha de Ingreso: marzo-2011
Ubicación: Punta de Mata
Mensajes: 106
Antigüedad: 13 años, 1 mes
Puntos: 0
Insertar textarea

Hola necesita su gran ayuda para este codigo, este se trada de que al colocar en el textarea "@" y cualquier letra coloque usuarios al hacer clic insertarlo pero no funciona lo cambie por que era para div pero necesito su ayuda

Código Javascript:
Ver original
  1. $(document).ready(function()
  2. {
  3.  
  4. var start=/@/ig;
  5. var word=/@(\w+)/ig;
  6.  
  7. $("#contentbox").keyup(function()
  8. {
  9. var content=$(this).val();
  10. var go= content.match(start);
  11. var name= content.match(word);
  12. var dataString = 'searchword='+ name;
  13.  
  14. if(go.length>0)
  15. {
  16. $("#msgbox").slideDown('show');
  17. $("#display").slideUp('show');
  18. $("#msgbox").html("Type the name of someone or something...");
  19. if(name.length>0)
  20. {
  21. $.ajax({
  22. type: "POST",
  23. url: "boxsearch.php",
  24. data: dataString,
  25. cache: false,
  26. success: function(html)
  27. {
  28. $("#msgbox").hide();
  29. $("#display").html(html).show();
  30. }
  31. });
  32.  
  33. }
  34. }
  35. return false();
  36. });
  37.  
  38. $(".addname").click(function()
  39. {
  40. var username=$(this).attr('title');
  41. var old=$("#contentbox").val();
  42. var content=old.replace(word,"");
  43. $("#contentbox").val(content);
  44. var E=""+username+"";
  45. $("#contentbox").append(E);
  46. $("#display").hide();
  47. $("#msgbox").hide();
  48. $("#contentbox").focus();
  49. });
  50.  
  51. });