Ver Mensaje Individual
  #3 (permalink)  
Antiguo 23/02/2012, 14:07
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: Lineas textarea

Otra opción (porque a veces la aparición de un renglón puede deberse al flujo normal del texto en relación al ancho del contenedor y no sólo a los saltos de línea), sería calcular el alto total del área scrolleable sobre el alto de línea:
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=utf-8" />

<
title>Documento sin título</title>
<
style>
textareawidth:80pxheight:50pxline-height:15pxfont-size:12px;}
</
style>
<
script type="text/javascript">
function 
getCSS(o,prop){
    if(
window.getComputedStyle){
        return 
document.defaultView.getComputedStyle(o,null).getPropertyValue(prop); 
    }else{ 
        var 
re = /(-([a-z]){1})/g
        if (
prop == 'float'prop 'styleFloat'
        if (
re.test(prop)) { 
            
prop prop.replace(re, function () { 
                return 
arguments[2].toUpperCase(); 
            }); 
        } 
        return 
o.currentStyle[prop] ? o.currentStyle[prop] : null
    } 
}  
onload=function(){
    var 
c=document.getElementById('area');
    var 
cuantos=c.scrollHeight/parseInt(getCSS(c,'line-height'));
    
alert(cuantos);
}
</script>

</head>

<body>
<form action="" method="get"><textarea id="area" name="" cols="">Hah
Hahye hahye aye hahye
Om maam na pum imjya
Kothbiro
Ke luru do ketaa-lha
Om maam pum imjya
Kothbiro
Ke luru do ketaa-lha
Hah
Hahye hahye aye hahye
Om maam pum imjya
Kothbiro
Ke luru do ketaa-lha
Om maam na pum imjya
Kothbiro
Ke luru do ketaa-lha
ah
Hahye hahye hahye
Hah
Hahye hahye hahye
Yah yebi tom nuguee
Um kuru tili bare made
Kothbiro
Kem luru do ketaa-lha</textarea></form>
</body>
</html>