Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > cgi clearing a form

Reply
Thread Tools

cgi clearing a form

 
 
mcvallet@hotmail.com
Guest
Posts: n/a
 
      03-23-2006
Hi,
I am writing a dynamical quiz and and once this quiz is submitted, I
display the answers. the problem is that when I submit the form without
answering the question in the display, I still get 'answers' that where
submitted previously.
I tried several thing like :
in the writing the form
#create the new writer
my $cgiWriter = new CGI("");
#reset any possible values kept previously
$cgiWriter->delete_all();

in correcting the form :
#create the new writer
my $cgiWriter = new CGI("");
some code
foreach my $p ( param() ) {

$form{$p} = param($p);

}

$cgiWriter->delete_all();
but it does not seem to work. could someone help me,
thanks

 
Reply With Quote
 
 
 
 
Mike Paolucci
Guest
Posts: n/a
 
      03-23-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hi,
> I am writing a dynamical quiz and and once this quiz is submitted, I
> display the answers. the problem is that when I submit the form without
> answering the question in the display, I still get 'answers' that where
> submitted previously.
> I tried several thing like :
> in the writing the form
> #create the new writer
> my $cgiWriter = new CGI("");
> #reset any possible values kept previously
> $cgiWriter->delete_all();


> in correcting the form :
> #create the new writer
> my $cgiWriter = new CGI("");
> some code
> foreach my $p ( param() ) {


> $form{$p} = param($p);


> }


> $cgiWriter->delete_all();
> but it does not seem to work. could someone help me,
> thanks


You haven't said explicitly, but I suspect these "answers" are being
input through an HTML textarea control. If this is the case then you
should do something like this:

my $reset = <set $reset based on some criteria for clearing the form>;

then later on in your code ...

textarea( -name => 'answer10',
-value => param( 'answer10' ),
-override => $reset,
-default => '',
-rows => 10,
-columns => 80 )

If -override is "true" then the -default value is used
(regardless of the value in -value).


I haven't looked at any other HTML controls in CGI.pm, but I
suspect that the other controls may have something similar.

HTH
 
Reply With Quote
 
 
 
 
mcvallet@hotmail.com
Guest
Posts: n/a
 
      03-23-2006
thank, it work very well for the texfields and textareas but i still
have a problem with my radio buttons :
#declaration of the variables are at the beginning of my code

if ($answerGiven =~ m/$answerIndex/i){#if the radio button was checked
before than check it again
print $cgiWriter->radio_group(
-name => "$name" #name of the group
,-values => \%labels #list of values for the radio buttons
(two values only value and the "seen value"
,-linebreak => 'true' #puts line breaks between the buttons,
creating a vertical list
,-checked => "" #no default value is selected
,-readonly => ""
, -override => 1


);
}else{#if the radio buton was not checked before than don't check it
print $cgiWriter->radio_group(
-name => "test$name" #name of the group
,-values => \%labels, #list of values for the radio buttons
,-linebreak => 'true' #puts line breaks between the buttons,
creating a vertical list
,-default => "" #no default value is selected
,-readonly => ""
, -override => 1
);
}
and second question that I would like to know you can readonly on
textfield/area but it does not seem to work with radio buttons is there
a way to do it ?
thanks again,
mc

 
Reply With Quote
 
mcvallet@hotmail.com
Guest
Posts: n/a
 
      03-23-2006
never mind, it works also with the radio buttons, this was my problem :
$answerGiven =~ m/$answerIndex/i instead of writing $answerIndex =~
m/$answerGiven/i
thank you ,
mc

 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      03-23-2006
(E-Mail Removed) wrote:
> Hi,
> I am writing a dynamical quiz and and once this quiz is submitted, I
> display the answers. the problem is that when I submit the form without
> answering the question in the display, I still get 'answers' that where
> submitted previously.


perhaps:
use CGI qw(-nosticky);
?

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript for Form (using CGI formmail) that sends user a copy ofthe form data TPK Javascript 1 08-27-2010 12:49 PM
CGI (read multipart form): Accept-Charset encoding error (CGI::InvalidEncoding) Stefan Fischer Ruby 2 02-23-2010 08:17 AM
New Service for CGI form submissions - Form-Submit.com ultranate@gmail.com ASP General 0 01-12-2006 08:21 PM
Re: regarding cache clearing header in python cgi Fredrik Lundh Python 0 06-21-2005 09:38 AM
regarding cache clearing header in python cgi praba kar Python 0 06-21-2005 06:26 AM



Advertisments