On Sunday 29 February 2004 17:20, [EMAIL PROTECTED] generously enriched
virtual reality by making up this one:
Hi
> I have a script that processes a form input. What I want to do is this:
I assume you are talking about a html form.
> I have form elements:
>
> -radio_group1
> -radio_group2
>
> -textfield: takes 6 digits depending on the user' selection.
>
> I want the textfield to be populated with 000000 if the user select
> radio_group2.
>
> Any idea on how to do that and thanks in advance!
---snip---
#! /usr/bin/perl
use strict;
use warnings;
use CGI qw(:standard);
my $p = new CGI;
my $myself =$p->url;
my $text;
if ($p->param){
if ($p->param('radio') eq 'take') {$text=$p->param('textfield');}
else {$text='000000';}
print
$p->start_html('Results'),
$p->h1('Results'),
$p->p("$text"),
$p->end_html;
}
else {
print
$p->start_html('Form'),
$p->start_form(), #defaults are this script, post, x-www-urlencoded
$p->textfield(-name=>'textfield'),
$p->radio_group(-name=>'radio', -values=>['take','delete']),
$p->submit,
$p->end_form,
$p->end_html;
}
---snap---
prints a form with two radiobuttons (in the same group, 'radio') if the script
s caled without parameters.
If parameters are returned, $text is set to the content of your texfield if
radio=take, otherwise $txt is se to '000000'.
Read the CPAN docu for the CGI module if you need help with it - tons of
examples.
Enjoy, Wolf
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>