Leser: 21
1
2
3
4
5
<form action=alig.pl method=get>
<input type="checkbox" name="alignment_seq" value="a">
<input type="checkbox" name="alignment_seq" value="b">
<input type=submit value=c>
<\form>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/perl use strict; use warnings; use CGI; my $cgi = CGI->new; # erzeuge neues CGI-Objekt my %params = $cgi->Vars; # hole die parameter print CGI->header; if ( !$params{alignment_seq} ) { print "Du hättest eine Checkbox wählen müssen!"; }
2010-07-02T11:11:46 reneeNein schenken muss man sich das JS nicht.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<script type="text/javascript">
function checkboxes(elm) {
var checkboxes = 0;
for (i=0; i<elm.alignment_seq.length; i++){
if (elm.alignment_seq[i].checked==true) {
checkboxes++;
break;
}
}
if (!checkboxes) {
alert("Keine Checkbox aktiviert!");
return false;
}
return true;
}
</script>
<form name="testformular" action="alig.pl" method="get" onsubmit="return checkboxes(this)">
<input type="checkbox" name="alignment_seq" value="a">
<input type="checkbox" name="alignment_seq" value="b">
<input type="submit" value="c">
</form>
1 2 3
<input type="checkbox" name="alignment_seq" value="a"/> <input type="checkbox" name="alignment_seq" value="b"/> <input type="submit" value="c"/>