RE: only first checked item passed
Prachi Shah wrote: > Hi all, > > I have a CGI script which does a select on a database and > builds a checkbox > group iterating through the result of the select. The problem > is when a user > submits the form, only the first checked item in the checkbox > group is > passed. How do you know only the first checked item is being passed? How are you retrieving the parameter values? I assume you're seeing multiple checkboxes on the screen, so your generate code is probably OK. All the checkboxes have the same name, so you need to call param() in list context to get them all. If you call it in scalar context, you're only going to get the first. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: only first checked item passed
So, any other ideas? Original Message Follows From: [EMAIL PROTECTED] (Randal L. Schwartz) To: [EMAIL PROTECTED] Subject: Re: only first checked item passed Date: 22 Aug 2003 07:12:24 -0700 >>>>> "Nyimi" == Nyimi Jose <[EMAIL PROTECTED]> writes: Nyimi> Try Nyimi> (@rows)=$sth->fetchrow_array; Nyimi> Not Nyimi> @rows=$sth->fetchrow_array; Doesn't make a bit of difference. Useless parens there. Makes a difference only in: ($foo) = .. vs $foo = .. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ MSN 8: Get 6 months for $9.95/month. http://join.msn.com/?page=dept/dialup -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: only first checked item passed
> "Nyimi" == Nyimi Jose <[EMAIL PROTECTED]> writes: Nyimi> Try Nyimi> (@rows)=$sth->fetchrow_array; Nyimi> Not Nyimi> @rows=$sth->fetchrow_array; Doesn't make a bit of difference. Useless parens there. Makes a difference only in: ($foo) = .. vs $foo = .. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: only first checked item passed
Try (@rows)=$sth->fetchrow_array; Not @rows=$sth->fetchrow_array; José. -Original Message- From: Prachi Shah [mailto:[EMAIL PROTECTED] Sent: Thursday, August 21, 2003 11:06 PM To: [EMAIL PROTECTED] Subject: only first checked item passed Hi all, I have a CGI script which does a select on a database and builds a checkbox group iterating through the result of the select. The problem is when a user submits the form, only the first checked item in the checkbox group is passed. Below is the snippet of the perl code that generates the checkbox group. Please advise me if there is anything I am doing wrong. Any help is appreciated. Thanks, Prachi. ### cut code if (!$sth) { $sth = $dbh->prepare("SELECT * FROM " . $schema . "dberge_ranges WHERE chrom = ? " . "AND start_pt <= ? AND stop_pt >= ? ORDER BY id, start_pt"); } $sth->execute($chr, $stp, $st); my(@row) = $sth->fetchrow_array; #print "@row\n"; if ([EMAIL PROTECTED]) { print $q->strong("No results and Expression data found\n"), $q->br; }else { print $q->strong("Experimental results of gene expression"), $q->br; print $q->start_form(-action => $dberge_url); print $q->br; print $q->start_table({-border=>1}), $q->Tr, $q->td("ExperimentID Assay"), $q->td("range affected"); my $pid = 0; while (@row) { $row[3] = commify($row[3]); $row[4] = commify($row[4]); if ($pid == $row[0]) { #same variant another range if ($row[3] ne $row[4]) { print $q->br, "$row[2] $row[3] - $row[4]"; }else { print $q->br, "$row[2] $row[3]"; } }else { #new dberge entry print $q->Tr; print $q->td( $q->checkbox(-name=>'id', -value=>$row[0], -label=>"$row[0] $row[1]")); if ($row[3] ne $row[4]) { print $q->td, "$row[2] $row[3] - $row[4]"; #may continue }else { print $q->td, "$row[2] $row[3]"; } } $pid = $row[0]; @row = $sth->fetchrow_array; } print $q->br; print $q->end_table; print $q->br; print $q->hidden("mode", "Submit query"), $q->hidden("disp","All data"); print $q->submit(-name=>"View", -value=>"Submit"); end cut code ### _ Chat privately with Bon Jovi, Seal, Bow Wow, or Mary J Blige using MSN Messenger! http://www5.msnmessenger-download.com/imastar/default.aspx -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] DISCLAIMER "This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer". Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
only first checked item passed
Hi all, I have a CGI script which does a select on a database and builds a checkbox group iterating through the result of the select. The problem is when a user submits the form, only the first checked item in the checkbox group is passed. Below is the snippet of the perl code that generates the checkbox group. Please advise me if there is anything I am doing wrong. Any help is appreciated. Thanks, Prachi. ### cut code if (!$sth) { $sth = $dbh->prepare("SELECT * FROM " . $schema . "dberge_ranges WHERE chrom = ? " . "AND start_pt <= ? AND stop_pt >= ? ORDER BY id, start_pt"); } $sth->execute($chr, $stp, $st); my(@row) = $sth->fetchrow_array; #print "@row\n"; if ([EMAIL PROTECTED]) { print $q->strong("No results and Expression data found\n"), $q->br; }else { print $q->strong("Experimental results of gene expression"), $q->br; print $q->start_form(-action => $dberge_url); print $q->br; print $q->start_table({-border=>1}), $q->Tr, $q->td("ExperimentID Assay"), $q->td("range affected"); my $pid = 0; while (@row) { $row[3] = commify($row[3]); $row[4] = commify($row[4]); if ($pid == $row[0]) { #same variant another range if ($row[3] ne $row[4]) { print $q->br, "$row[2] $row[3] - $row[4]"; }else { print $q->br, "$row[2] $row[3]"; } }else { #new dberge entry print $q->Tr; print $q->td( $q->checkbox(-name=>'id', -value=>$row[0], -label=>"$row[0] $row[1]")); if ($row[3] ne $row[4]) { print $q->td, "$row[2] $row[3] - $row[4]"; #may continue }else { print $q->td, "$row[2] $row[3]"; } } $pid = $row[0]; @row = $sth->fetchrow_array; } print $q->br; print $q->end_table; print $q->br; print $q->hidden("mode", "Submit query"), $q->hidden("disp","All data"); print $q->submit(-name=>"View", -value=>"Submit"); end cut code ### _ Chat privately with Bon Jovi, Seal, Bow Wow, or Mary J Blige using MSN Messenger! http://www5.msnmessenger-download.com/imastar/default.aspx -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]