in reply to Re: how to make dependent drop down in perl script
in thread how to make dependent drop down in perl script

Best guess is that you forgot to print the Content-Type header before the loop you have shown us. Working SSCCE:

#!/usr/bin/env perl use strict; use warnings; print "Content-type: text/plain\n\n"; my %folderhash2 = ( '1005' => 'SG', '1007' => 'NA', '1010' => 'Global', '0' => 'None', '1006' => 'Link', ); foreach my $folderMap2 (sort keys %folderhash2) { printf "%-8s %s\n", $folderMap2, $folderhash2{$folderMap2}; }

🦛

  • Comment on Re^2: how to make dependent drop down in perl script (missing header)
  • Download Code

Replies are listed 'Best First'.
Re^3: how to make dependent drop down in perl script (missing header)
by Anonymous Monk on Apr 28, 2023 at 20:12 UTC
    Thanks so much for quick reply : I have added the print "Content-type: text/plain\n\n"; but still the output is not as expected :
    0 None 1005 SG Desk Reports 1006 LN Desk Reports 1007 NA Desk Reports 1008 Saudi Desk Reports 1010 Global Reports
    Content-Type: text/html; charset=ISO-8859-1
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S"> <head> <title>MSIM Equity</title> <link rel="stylesheet" type="text/css" href="../css/master.css" /> <link rel="stylesheet" type="text/css" href="../css/basic.css" /> <link rel="stylesheet" type="text/css" href="../css/imasg-onelook.css" + /> <link rel="stylesheet" type="text/css" href="../css/imasg-eod.css" /> <script src="../js/signoff.js" type="text/javascript"></script> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +" /> </head> <body id="ctl00_Body"> <div id="header"><h1 class="logo"><img src="../images/ms-logo.gif" alt +="Morgan Stanley" /></h1><h1 class="logo-print"><img src="../images/m +s_logo_grey.gif" alt="" /></h1><h1 id="site-title">MSIM Equity Report +s Signoff</h1><div id="utility-nav"><ul><li style="color:#ccffff">Wel +come: Ajay Kumar Srivastava&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</ +li><br /><br /><li style="color:#ccffff">Contact Us: 212-762-0194 </l +i></ul></div></div><div id="navigation"><div id="primary-nav"><ul><li +><a title="Home" href="signoff.cgi?rm=main">Home</a></li><li><a title +="Delinquency Report" href="signoff.cgi?rm=delinq_report">Delinquency + Report</a></li><li><a title="View Report" href="signoff.cgi?rm=view_ +report&amp;fId=0&amp;rId=0">View Report</a></li></ul></div></div><br +/><br /><form method="post" action="/signOffPageOnDev/cgi/signoff.cgi +?rm=view_report&amp;fId=0&amp;rId=0" enctype="multipart/form-data" on +load="setDefaultFolderName()" name="reportDetails" id="reportDetails" +> <br /><div class="column-module"><div class="title-bar"><div class="te +xt">View Report</div></div><br /><br />1

      If your data is HTML then obviously print an HTML Content Type rather than a plain text one.

      print "Content-type: text/html\n\n";

      Your post is was confusing. Please enclose your output inside <code> tags so that we can tell what it really is.

      Updated - thanks Corion for editing the parent to add the code tags.


      🦛

        Please find the below related code that short the drop down value. In this , I want to Set 'None' as selected in dropdown when page get load initially,

        my %folderMapFinal; #print $q->header; print "Content-type: text/plain\n\n"; print "Content-type: text/html\n\n"; foreach my $folderMap (sort keys %folderhash) { print STDERR "INSIDE FOR LOOP FOR FOLDERMAP\n"; %folderMapFinal =$folderMap; printf "%-8s %s\n\n", $folderMap, $folderhash{$folderMap}; } $q->div( { -class => "text" }, "Folder Name* : ", #my $defaultVal ='0', $q->popup_menu( -name=>'foldernameval', -id=> 'folder_name_id', -onChange => 'getReportName()', -type=>'dropdown', #-values=> \%folderhash, -values=> \%folderMapFinal, #-default=>$defaultVal, -default=>['0'], ), $q->hidden( -name => ('folder_name', -id=> 'h_folder_name_id', -va +lue => '' )), #$q->a( { -href => "signoff.cgi?rm=view_report&fId=3", -onClick => + 'setFolderNameId()', -title => "Populate Report Name" }, "Populate +Report Name" ), ),$q->end_div, $q->br, $q->br, $q->div( { -class => "text" }, "Report Name* : ", $q->popup_menu( -name=>'reportnameval', -id=> 'report_name_id', -onchange => 'setReportId()', -type=>'dropdown', -values=> \%reportHash, -default=>['0'], ), $q->hidden( -name => ('report_name', -id=> 'h_report_name_id', -va +lue => '' )), #$q->a( { -href => " ", -onClick => 'setFolderNameIdInURL()', -ti +tle => "Populate Report Name" }, " Click here to Populate Report Name +" ),
        Please find the below code :
        my %folderMapFinal; #print $q->header; #print "Content-type: text/plain\n\n"; print "Content-type: text/html\n\n"; foreach my $folderMap (sort keys %folderhash) { %folderMapFinal =$folderMap; printf "%-8s %s\n\n", $folderMap, $folderhash{$folderMap}; } $q->div( { -class => "text" }, "Folder Name* : ", #my $defaultVal ='0', $q->popup_menu( -name=>'foldernameval', -id=> 'folder_name_id', -onChange => 'getReportName()', -type=>'dropdown', #-values=> \%folderhash, -values=> \%folderMapFinal, #-default=>$defaultVal, -default=>['0'], ), $q->hidden( -name => ('folder_name', -id=> 'h_folder_name_id', -va +lue => '' )), #$q->a( { -href => "signoff.cgi?rm=view_report&fId=3", -onClick => + 'setFolderNameId()', -title => "Populate Report Name" }, "Populate +Report Name" ), ),$q->end_div, $q->br, $q->br, $q->div( { -class => "text" }, "Report Name* : ", $q->popup_menu( -name=>'reportnameval', -id=> 'report_name_id', -onchange => 'setReportId()', -type=>'dropdown', -values=> \%reportHash, -default=>['0'], ), $q->hidden( -name => ('report_name', -id=> 'h_report_name_id', -va +lue => '' )), #$q->a( { -href => " ", -onClick => 'setFolderNameIdInURL()', -ti +tle => "Populate Report Name" }, " Click here to Populate Report Name +" ), ),$q->end_div,