[ back to toc ]

finding the value that wasn't chosen

Date: 2002/06/10 13:04

I'm looking for the easiest way to find the value of a radio button that
was NOT chosen. I have used:
if (param()) {
@keys = param();
foreach $key (@keys) {
push @matches, param($key);
in order to get all the winners, and:

push @players, (param('username'));
open (MYFILE, ">players.txt") or die ("Couldn't open Players.txt\n");
print MYFILE join ("\n", @players);
close (MYFILE);

to get the whole list of values from all radio buttons which was derived
from user input from a previous page. @players is set up in order where
player 1 vs player 2, player 3 vs player 4 and so on so if player 1 was
the winner which would be $players[0] then player 2 ($players[1]) would be
the loser. I'm trying to print out the winners defeated the losers. Sorry
for rambling on but hope i provided enough info. The opening line from
code is:

#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use strict;
use CGI qw(:standard);


Web forms send to the server the value along with the key of the radio
selections that were selected but not the ones that were not selected.
Therefore your program has to have a-priory knowledge of what kind of
radio buttons on the form is/was when the form data arrives onto the CGI

One way to do this to alter the script that generates the page with the
form and list all the players in hidden fields.


[ back to toc ]