Thread View: pl.comp.lang.perl
3 messages
3 total messages
Started by cresimpl
Fri, 15 Oct 2010 07:57
checkbox i petla while
Author: cresimpl
Date: Fri, 15 Oct 2010 07:57
Date: Fri, 15 Oct 2010 07:57
24 lines
1817 bytes
1817 bytes
Witam
Mam taki problem:
W miejscu XxX chce wrzucic chechkbox-a jednak gdy wklejam tam kod w
stylu:
<input type="checkbox" name="cb" /> to wyrzuca blad w przegladarce.
Dane sa wczytywane z pliku i rozkladane na tabele. W karzdym wersie
tabeli, chcialbym automatycznie dodawac chceckboxa.
FRAGMENT KODU:
open AA,"baza/users/idu_all.dat";
$scalar = <AA>;
$i = 1;
while ($scalar = <AA>) {
@lista = split(' ', $scalar);
print "<tr><td> XxX </td><td>$i</td><td>@lista[0]</td></tr>";
$i++;
}
print "</table>";
close AA;
Co mam zrobic, zeby obok danych wrzucanych do tabeli z pliku, byl
checkbox, dzieki ktoremu bede mogl edytowac dany wers?
Re: checkbox i petla while
Author: cresimpl
Date: Fri, 15 Oct 2010 08:54
Date: Fri, 15 Oct 2010 08:54
24 lines
1899 bytes
1899 bytes
hmmm... troche pozmienialem i zzaczelo dzialac. Nie wiem dokladnie
czemu wczesniej mi nie dzialalo i co robilem zle. Mozliwe ze zabraklo
wczesniej parametru value="" i to generowalo blad.
Oto kod po zmianach dzialajacy (choc wczesnij chyba robilem tak
samo?!?!):
while ($scalar = <AA>) {
@lista = split(' ', $scalar);
print <<END;
<tr>
<td><input type="checkbox" name="ng" value="gh" /></td>
<td>$i</td>
<td>@lista[0]</td>
<td>@lista[1]</td>
<td>@lista[2]</td>
<td>@lista[3]</td>
</tr>
END
$i++;
}
print "</table>";
close AA;
Re: checkbox i petla while
Author: Szymon Sokół
Date: Fri, 15 Oct 2010 21:56
Date: Fri, 15 Oct 2010 21:56
25 lines
2064 bytes
2064 bytes
On Fri, 15 Oct 2010 00:57:26 -0700 (PDT), cresimpl wrote:
> FRAGMENT KODU:
> open AA,"baza/users/idu_all.dat";
> $scalar = <AA>;
> $i = 1;
> while ($scalar = <AA>) {
> @lista = split(' ', $scalar);
> print "<tr><td> XxX </td><td>$i</td><td>@lista[0]</td></tr>";
> $i++;
> }
> print "</table>";
> close AA;
Pierwszy wiersz z pliku pomijasz, jak rozumiem, z premedytacją?
Oraz dobra rada: do generowania HTML używaj modułu CGI, albo jeszcze lepiej
CGI::Pretty; unikniesz wielu błędów typu niedomknięty tag, a w przypadku
tego drugiego modułu dodatkowo źródło w przeglądarce będzie ładnie
sformatowane.
--
Szymon Sokół (SS316-RIPE) -- Network Manager B
Computer Center, AGH - University of Science and Technology, Cracow, Poland O
http://home.agh.edu.pl/szymon/ PGP key id: RSA: 0x2ABE016B, DSS: 0xF9289982 F
Free speech includes the right not to listen, if not interested -- Heinlein H
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads