Ver Mensaje Individual
  #34 (permalink)  
Antiguo 03/11/2014, 16:24
Avatar de IsaBelM
IsaBelM
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 15 años, 10 meses
Puntos: 1012
Respuesta: Contar cantidad de oraciones y parrafos en textarea

releyendo el principio del tema, parece que es eso lo que quiere. no es complicado

todo se trata de conjugar css (line-heght), javascript (scrollHeight y getComputedStyle)

Código:
<!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=utf-8" />
<title></title>
<style type="text/css">
textarea#area {
    width: 200px;
    height: 150px;
    line-height: 15px;
    font-size: 13px;
}


textarea#area2 {
    width: 200px;
    height: 15px;
    line-height: 15px;
    font-size: 13px;
    overflow: hidden;
    visibility: hidden;
    position: absolute;
}
</style>
<script type="text/javascript">
function copypasteRaton() {

setTimeout(mostrarFilas, 0);
}


function mostrarFilas() {

    var texto = document.getElementById("area");
    var texto2 = document.getElementById("area2");
    texto2.innerHTML = texto.value.replace(/(\n+)/g, '\n');

    if (Math.floor(texto.scrollHeight / parseInt(window.getComputedStyle(texto, null)['line-height'])) >= 11) {

        texto2.style.height = window.getComputedStyle(texto, null)['height'];
        texto2.style.overflow = 'auto';
    }

    console.log(Math.floor(texto2.scrollHeight / parseInt(window.getComputedStyle(texto2, null)['line-height'])));

}
</script>
</head>
<body>

<textarea id="area2"></textarea>
<textarea id="area" onpaste="copypasteRaton()"></textarea>

</body>
</html>
__________________
if(ViolenciaDeGénero) {alert('MUJER ASESINADA');}