Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting unknown form input values

Status
Not open for further replies.

Skute

Programmer
Jul 21, 2003
272
GB
Hi,

i currently have a form which can have any number of unknown form values in it. for instance:

<input name=&quot;status_[% bugid FILTER html %]&quot; type=&quot;radio&quot; value=&quot;pass&quot;>

So one time there may be 2 sets of radio buttons with names:
status_37
status_65

Another time they might be:
status_9
status_15

I have a list of the different IDs needed seperated by &quot;,&quot; ie:
ids = 37,65,
ids = 9,15,

a) How can i break down the comma seperated list of ids into an array of ids
b) How can i get the values of the radio buttons?

cheers
 
Code:
#!/usr/bin/perl
use strict;
use CGI;
my $cgi_obj = new CGI;
print $cgi_obj->header,
    $cgi_obj->start_html;

my @params = $cgi_obj->param;
print '<ul>';
foreach (@params) { print &quot;<li>$_</li>\n&quot;; }
print '</ul>',
    $cgi_obj->end_html;

I think that will work.

'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
my @arrayname = (&quot;37&quot;,&quot;65&quot;,....);


as far as getting the values, you'll probably have to get te values of all form elements. then strip out everything but the radio buttons.

There's always a better way. The fun is trying to find it!
 
This is the code i used:

@bugids = split(/,/, $bugid);
for (my $i = 0; $i <= $#bugids; $i++) {
detaint_natural($bugids[$i]) || ThrowUserError(&quot;invalid_bug_id&quot;);
my $status_name = &quot;status_&quot; . $bugids[$i];
my $outcome_name = &quot;outcome_&quot; . $bugids[$i];
$results{$bugids[$i]} = $::FORM{$status_name};
$outcome{$bugids[$i]} = $::FORM{$outcome_name};
}

It works well :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top