in reply to Attribute values are not passed into the variable using perl cgi?

Your code does not compile, and your question is unclear.

I have attempted to correct it - and this code should get you the expected "submit=a1" in the querystring on hitting "submit".

Also - naming your sub "header" in a CGI program is a bad idea. I changed it to MyHeader.

uuse strict; use warnings; use DBI; use Getopt::Long; use CGI qw/:all :cgi-lib/; my $CGI_params = Vars(); my %CGI_PARAM = %$CGI_params; my $site = ""; my $site_selected="a1"; $site = "a1"; $site_selected = $CGI_PARAM{'popup'}; $site = $CGI_PARAM{'popup'}; if($site_selected =~ /^\s*$/) { $site = "a1"; $site_selected="a1"; } defined $site or die "usage:$0"; my %map=(a1=>[qw(r_a1_c)],a1=>[qw(r_a2_c)],); show(); sub show{ status(); MyHeader(); } sub status{ my $stm=$site_selected; } sub MyHeader { print start_form(-method=>"GET",-action=>"db.cgi"); print " <br> &nbsp<B>Site</B> &nbsp"; print popup_menu( -name => 'popup', -value => keys % map, -default => 'value2' ); print "&nbsp &nbsp &nbsp &nbsp &nbsp"; print submit(-type=>"submit",-name=>"submit",-value=>$site); print end_form, "\n"; }

        ...it is unhealthy to remain near things that are in the process of blowing up.     man page for WARP, by Larry Wall

  • Comment on Re: Attribute values are not passed into the variable using perl cgi?
  • Download Code

Replies are listed 'Best First'.
Re^2: Attribute values are not passed into the variable using perl cgi?
by huck (Prior) on Apr 11, 2017 at 05:39 UTC
      Interesting psychological condition discussed in those links.

      Thank you for the education on a new kind of troll.

              ...it is unhealthy to remain near things that are in the process of blowing up.     man page for WARP, by Larry Wall

        eh no! do not confuse them NetWallah! If this is the case, this is not a troll: is a shapeshifter.. ;=)

        L*

        There are no rules, there are no thumbs..
        Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      ... this is his 4th userid ... he has had this all pointed out to him before ... Interesting nick name The total number of class rooms in GPS.SANA COMPOUND is 1.

      Suddenly many things become clear. It is not he but they who are registering all these user names and asking the same questions over and over again.

      As is often the case, answers engender more questions. Despite being in a very small school (from the link: thirty-nine students, two teachers, one classroom, four blackboards, no computers — which I take to mean that each student has his or her own laptop), they seem not to share info among themselves. Is this an indication of dedication to individual effort or of unwillingness to cooperate with and support their fellow students?


      Give a man a fish:  <%-{-{-{-<

        Linking the multiple user IDs (plus anonymous postings) is fairly sensible in this case, given the copy/paste crowd sourced code throughout the threads, and one user ID responding to a reply to one of the other clones. However linking one of the user IDs to a single match (name of a school) of a web search seems less wise to me.

        >  which I take to mean that each student has his or her own laptop

        Interesting theory, just...

        " School Category :Primary only "

        :)

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!

Re^2: Attribute values are not passed into the variable using perl cgi?
by gpssana (Initiate) on Apr 11, 2017 at 07:11 UTC
    the thing is -value=>$site should pass all 'popup'values.

      Add this line to top of your script and then fix the errrors

      use CGI::Carp 'fatalsToBrowser';


      the thing is -value=>$site should pass all 'popup'values.

      The thing should make sense, test, check, its basic debugging