Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Liczenie linii tekstu
Malinaa
post
Post #1





Grupa: Zarejestrowani
Postów: 577
Pomógł: 6
Dołączył: 21.07.2008

Ostrzeżenie: (0%)
-----


Szukam kodu lub funkcji, która liczy linie w tekście (w polu textarea). Znalazłem w pliku, ale textarea is not possible to find!
Byłoby w pipe dobrze, gdyby kod liczył słowa.

Ten post edytował Malinaa 10.01.2009, 22:22:17
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Largo
post
Post #2





Grupa: Zarejestrowani
Postów: 203
Pomógł: 6
Dołączył: 11.09.2005

Ostrzeżenie: (0%)
-----


Witam,

Nie wiem co w tym trudnego jest, ale OK...

  1. <?php
  2. function countLines(theArea){
  3. var theLines = theArea.value.replace((new RegExp(".{"+theArea.cols+"}","g")),"\n").split("\n");
  4. if(theLines[theLines.length-1]=="") theLines.length--;
  5. theArea.form.lineCount.value = theLines.length;
  6. }
  7. ?>


Potem sprawdzasz w zdarzeniu onKeyUp w polu TextArea.

PS. Google daje odpowiedź :-) Wyrażenie: count lines textarea

Pozdrawiam,
Largo
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 7.10.2025 - 21:16