Ver Mensaje Individual
  #2 (permalink)  
Antiguo 10/05/2010, 01:44
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: posicion de cursor en textarea

Probá así:
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title>ejemplo</title>
<
script>
function 
sel(inicio,fin,idCampo){
    
input=document.getElementById(idCampo);
    if(
typeof document.selection != 'undefined' && document.selection){
        
tex=input.value;
        
input.value='';
        
input.focus();
        var 
str document.selection.createRange();
        
input.value=tex;
        
str.move('character'inicio);
        
str.moveEnd("character"fin-inicio);
        
str.select();
    }
    else if(
typeof input.selectionStart != 'undefined'){
        
input.setSelectionRange(inicio,fin);
        
input.focus();
    }
}
</script>  
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <textarea name="area" cols="60" rows="10" id="area">Qué lindo perro.</textarea>
  <input type="button" name="Submit" value="-3" onclick="sel(document.getElementById('area').value.length-4,document.getElementById('area').value.length-4,'area')" /><input type="button" name="Submit" value="-5" onclick="sel(document.getElementById('area').value.length-6,document.getElementById('area').value.length-6,'area')" />
</form>
</body>
</html>