Thread "Check All" Button bei CGI und Checkboxen
(14 answers)
Opened by tecker at 2008-12-02 17:38
Naja so langsam komm ich da hin wo ich hin will mit meinem Programm. Inzwischen gehen auch meine JS-Funktionen.
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 my $js = q~ function checkAll(field) { for(i=0;i<field.length; i++) field[i].checked=true; } function uncheckAll(field) { for(i=0;i<field.length;i++) field[i].checked=false; } ~; [...] print $cgi->start_form({-name=>'form1',-action => "/pfad/script.pl", -method=>'post'}); print $cgi->start_table({-bordercolor=>'#cccccc', -bgcolor=>'#ffffff', -border=>'0', -width=>'700'}); while ($prepare_select_hosts->fetch()){ print $cgi->Tr( $cgi->td({-width=>'20'},$id), $cgi->td($hostname), $cgi->td($ip), $cgi->td($cgi->checkbox(-name=>'host', -label=>'', -value=>"$ip")) ); } print $cgi->Tr( $cgi->td({-colspan=>'3'}, $cgi->button(-name=>'checkall', -value=>'Check All', -onMouseOver =>"this.style.color = '#FF0000'", -onMouseOut => "this.style.color = '#000000'", -onClick=>"checkAll(document.form1.host);"), $cgi->button(-name=>'uncheckall', -value=>'Uncheck All', -onMouseOver =>"this.style.color = '#FF0000'", -onMouseOut => "this.style.color = '#000000'", -onClick=>"uncheckAll(document.form1.host);"), )); print $cgi->end_table(); print $cgi->end_form(); [...] |