Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

form problem...

by Nik (Initiate)
on Feb 26, 2004 at 10:58 UTC ( [id://331957]=perlquestion: print w/replies, xml ) Need Help??

Nik has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,
I'am trying to develop a database driver website that people will be able to order movies through it!
Well i am having trouble with the following code, i dont know how to make it work so ot be able to when the user picks a movie from the drop down menu then we will clikc the button pick next to it and then we will be able to choose another one for ie Movie 2 and so on until he hits the button Done. I want evry time the user presses the pick button the form index.pl to resubmit to itself but the prompt now will be the next movies for the user to pick. like this Movie 1 Pick resubmit Movie 2 Pick resubmit Movie 3 so that the visitor can pick as many movies as he likes until he pressed the Done button. Any ideas on how to proceed on that?
open(IN, '<movies.txt') or die $!; @tips = <IN>; close(IN); print start_form(-action=>'show.pl'); print table( {border=>1, -width=>'35%', -align=>'center', -style=>'bor +der: ridge lime; color: yellow; font-size: 20', -background=>'../data +/images/blue.jpg'}, Tr( {-align=>'center'}, td( 'Movie X' ), td( popup_menu(-name=>' +dvdX', -values=>[@tips] )), td( submit( 'Pick' ))), Tr( {-align=>'center'}, td( submit( 'Clear' )), td( submit( ' +Done' )))), br(), br(); print table( {border=>1, -width=>'35%', -align=>'center', -style=>'bor +der: ridge lime; color: yellow; font-size: 20', -background=>'../data +/images/blue.jpg'}, Tr( {-align=>'center'}, td( submit( 'Add' )), td( submit( 'Sh +ow' ))), Tr( {-align=>'center'}, td( submit( 'Modify' )), td( submit( 'De +lete' )))); print end_form(), br(), br();
Thank tou all!

Replies are listed 'Best First'.
Re: form problem...
by rdfield (Priest) on Feb 26, 2004 at 12:06 UTC
    You need to read up on user sessions and CGI parameter parsing ? Have a read of the CGI tutorials section: there's plenty of examples of how to maintain state across clicks.

    rdfield

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: form problem...
by Wonko the sane (Deacon) on Feb 26, 2004 at 14:12 UTC
    Hello,

    What you want to do is collect any previous movie selections
    and pass them on to the form through hidden fields.

    Something like this:

    my $hidden_fields; $hidden_fields .= $cgi->hidden( $_, $in{$_} ) for ( grep { /dvdX/ } ke +ys %in );
    Where %in is your hash if form vars retrieved from CGI->Vars.
    Just print out the list of hidden fields as part of your form everytime.

    Best Regards,
    Wonko

    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://331957]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (None)
    As of 2024-04-25 00:55 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found