Help creating multi page web form with perl CGI
I want to create a multi page web form using perl CGI that changes page based on a drop down selection. I have looked at tutorials for a multi page CGI form that only moves in order but I would like mine to be able to go to a different page based on the selection. I'm not sure how I should try to organize my different pages a开发者_StackOverflownd handle switching pages without getting messy. Any suggestions to how to organize and move throughout the pages would be a great help.
From the perspective of the CGI script, the which UI element is the source of the submission does not make any difference at all. That matters are the name/value pairs your script receives.
If you want the form to be submitted without the user having to click a submit button, you'll need to look at JavaScript as that is a client side issue, not a server one.
Have you looked into Catalyst
? An MVC architecture will control the code--if you know how to use it.
See:
Dropdown Form, when click on element, go to link without hitting a submit button
I would recommend against trying to use CGI for any new websites.
Instead I would recommend using one of the several frameworks that are now available.
Dancer
#!/usr/bin/perl use Dancer; get '/hi' => sub { "Hello World!" }; dance;
Mojolicious
#!/usr/bin/env perl use Mojolicious::Lite; # / get '/' => 'index'; # /* get '/:groovy' => sub { my $self = shift; $self->render_text($self->param('groovy'), layout => 'funky'); }; app->start; __DATA__ @@ index.html.ep % layout 'funky'; Yea baby! @@ layouts/funky.html.ep <!doctype html><html> <head><title>Funky!</title></head> <body><%= content %></body> </html>
Catalyst
( The simplest of which requires several files, but may be worth it for large websites )
精彩评论