The below is my perl code to populate the first drop down <Folder Name >
sub create_view_report { my $dbslave; my $self = shift; my $html; my $res = write_to_report(); my $q = new CGI; my $fId = $q->param ('fId'); if ( $fId=='' | $fId==' ' ){ print STDERR "--**IF BLOCK----------FOLDER ID IS BLANK :$fId \ +n"; #$fId=1005; }else{ print STDERR "------****ELSE BLOCK ------FOLDER ID IS BLANK :$ +fId \n"; #$fId=1005; } my $sql2 = "Select ID, link_name from dbo.equitytradereportsign +off_category"; my $result = &select_sql( $gDbh, $sql2 ); my ($soff, $m); my @foldernameval; push (@foldernameval, 'None'); my @foldernameid; push (@foldernameid, '0'); my %folderhash =('0' => 'None'); foreach ( @{$result} ) { ( $soff, $m ) = @{$_}; #print STDERR "ID--> $soff , Value -->$m\n"; $folderhash{$soff} = $m; } my $foldersize = keys %folderhash; #print STDERR "FOLDER SIZE : $foldersize\n"; my @reportnameval; push (@foldernameval, 'None'); my @foldernameid; push (@foldernameid, '0'); my %reporthash =('0' => 'None'); #1122 my $q = new CGI; my $fId ; $fId = $q->param ('fId'); if ( $fId=='' | $fId==' ' ){ print STDERR "*****===IF BLOCK----------FOLDER ID IS BLANK :$f +Id \n"; #$fId=1005; }else{ print STDERR "******===========****ELSE BLOCK ------FOLDER ID IS +NOT BLANK :$fId \n"; #$fId=1005; } #print STDERR "VIEW REPORT START and FOLDER ID :$fId \n"; my $reportsql ; my %reportHash =('0' => 'None'); if($fId !=0 ){ print STDERR "INSIDE IF BLOCK THE VALUE OF fId = $fId\n"; $reportsql = "SELECT report_type_id, sub_link_name FROM dbo. +equitytradereportsignoff_sub_category where Cat_ID = $fId"; print STDERR "REPOERT NAME SQL : $reportsql\n"; my $reportResult = &select_sql( $gDbh, $reportsql ); my ($reportId, $reportName); my @reportVal; push (@reportVal, 'None'); my @reportnameid; push (@reportnameid, '0'); %reportHash =('0' => 'None'); foreach ( @{$reportResult} ) { ( $reportId, $reportName ) = @{$_}; print STDERR "REPORT-ID--> $reportId , REPORT-NAME -->$ +reportName\n"; $reportHash{$reportId} = $reportName; } } open( HTML, '>', \$html ) || die "could not open HTML in memory f +ile handle: $!\n"; my $q = $self->query(); print_header( self_obj => $self, access_entitle => 'no' ); print HTML $q->startform( -method => 'GET' ), $q->br, $q->start_div( { -class => "column-module" } ), $q->start_div( { -class => "title-bar" } ), $q->div( { -class => "text" }, "View Report", ),$q->end_div, $q->br, $q->br, $q->div( { -class => "text" }, "Folder Name : ", #my $defaultVal ='0'; $q->popup_menu( -name=>'foldernameval', -id=> 'folder_name_id', -onchange => 'getReportName()', -type=>'dropdown', -values=> \%folderhash, #-default=>$defaultVal, -default=>['0'], ), $q->hidden( -name => ('folder_name', -id=> 'h_folder_name_id', -va +lue => '' )), ),$q->end_div, $q->br, $q->br, $q->div( { -class => "text" }, "Report Name : ", $q->popup_menu( -name=>'reportnameval', -id=> 'report_name_id', #-onchange => 'getReportName()', -type=>'dropdown', -values=> \%reportHash, -default=>['0'], ), $q->hidden( -name => ('report_name', -id=> 'h_report_name_id', -va +lue => '' )), #$q->a( { -href => "signoff.cgi?rm=view_report&fId=\'$fId\'", -on +Click => 'setFolderNameId()', -title => "Populate Report Name" }, "P +opulate Report Name" ), $q->a( { -href => "signoff.cgi?rm=view_report&flag=1&fId='$fId'", +-onClick => 'setFolderNameId()', -title => "Populate Report Name" }, + "Populate Report Name" ), #$q->a( { -href => "signoff.cgi?rm=view_report&fId=$fId", -title +=> "Populate Report Name" }, "Populate Report Name" ), ),$q->end_div, $q->br, $q->br, #2233 working code print STDERR "BEFORE REPORT NAME : \n"; #$q->div( { -class => "text" }, "Report Name : ", $q->popup_menu(- +name=>'dropdown',-id=> 'report_name_id', -values=>['None','One','Two' +,'Three','Four','Five']), ), #$q->end_div, $q->br, $q->br, $q->div( { -class => "text" }, "From Date : ", $q->td("<input name +='fdate' type='date'>"), "\t\tTo Date : ", $q->td("<input name='tda +te' type='date'>"),),$q->end_div, $q->br, $q->br, $q->submit(-value => 'Search'); #table added by ajay start #my %labels = ('value1'=>'label1', 'value2'=>'label2', 'value3 +'=>'label3'); #my %attributes = ('value1'=>{'id'=>'1'},'value2'=>{'id'=>'2'} +,'value3'=>{'id'=>'3'}); #print $q->popup_menu('menu_name', ['value1','value2','value3' +], 'value2',\%labels,\%attributes); #table added by ajay end $q->end_div, $q->br, $q->br, $q->br, $q->br, $q->endform, $q->br, $q->br, $q->end_html; close(HTML); return $html; }

2023-03-11 Athanasius added code tags.


In reply to Re^2: how to make dependent drop down in perl script by Anonymous Monk
in thread how to make dependent drop down in perl script by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.