Hi Wise Perl people, I have a perl Cgi script which has 2 text fields where I ask user to input date. A more elegant solution would be to have a javascript dropdown calendar. I will add my code at the end of this email which uses the cgi startform() function. I am a newbie at javascript. I am not sure if perlmonks is the place for advise on this, but any help is appreciated. Perlmonks has been a wonderful support tool so far. I have some more code after endform to show how I am getting the param values for date. Regards, Rakhee
#!/usr/bin/perl -w # # # This is the HTML form for selecting projects for QA Metrics # use lib qw(/tools/local/lib/perl5); use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use DBI; use GD::Graph::linespoints; $cgi= new CGI; my @timedata = localtime(time); #print "Content-type: text/html\n\n"; #print "@timedata[0]\n, @timedata[1]\n, @timedata[2]\n,@timedata[3]\n, +@timedata[4]\n,@timedata[5]\n,@timedata[6]"; $day = @timedata[3]; $month = @timedata[4] + 1; $year = 1900 + @timedata[5]; $def_start_date = '31/3/2009'; $today_date = join('/',$day,$month,$year); $def_end_date = $today_date; #print "Content-type: text/html\n\n"; #print "$def_end_date"; if (!$cgi->param) { print $cgi->header; print $cgi->start_html(-title=>'Project Selection', -style => {'src'=> +'http://wwwin.telegent.com/sqametrics/style1.css'}); print $cgi->startform; print $cgi->h3('Select Project to view QA Metrics'); print $cgi->br; print $cgi->br; print "<em><b>Enter Start Date [dd/mm/yyyy]</b></em><br>"; print $cgi->textfield(-name=>'start_date', -default=>$def_start_date, -size=>9, -maxlength=>80); print $cgi->br; print $cgi->br; print "<em><b>Enter End Date [dd/mm/yyyy]</b></em><br>"; print $cgi->textfield(-name=>'end_date', -default=>$def_end_date, -override=>true, -size=>9, -maxlength=>80); print $cgi->br; print $cgi->br; print $cgi->br; print "<b>Select Project and DataType to View QA Metrics </b><br>" +; print $cgi->br; print $cgi->scrolling_list(-name=>'Projects', -value=>[ 'ARES', 'POSEIDON_SW', 'DEIMOS', 'MIMAS', 'JUPITER', 'POSEIDON', 'DIONYSUS'], -size=>7, -multiple=>'false', -default=>'ARES'); print $cgi->br; print $cgi->br; print $cgi->br; print "<b>Select Check Box for Plotting Verified, Closed Bug Data< +/b><br>"; print $cgi->br; print $cgi->checkbox(-name=>'verified_closed', -checked=>0, -value=> 'verified-closed'); print $cgi->br; print $cgi->br; print "<b>Select from P1, P2, or P1+P2 Bugs Data</b><br>"; print $cgi->br; print $cgi->radio_group(-name=>'P1P2_bugs', -values=> ['P1', 'P2','P1-P2','Daily-Snapshot'], -default=>['P1'], -linebreak=>'true'); print $cgi->br; print $cgi->submit(-value=>'Submit Project'); print $cgi->endform; print $cgi->end_html; } else { my $start_date = param('start_date'); my $end_date = param('end_date'); my $error_msg = ""; my $error_msg = &validate_date($start_date, $end_date, $today_date); #print "Content-type: text/html\n\n"; #print $today_date; # my $error_msg = ""; # if (!$start_date){ # $error_msg1 = "The Start Date Field is Blank. Please use Browser +Back button and enter a Valid Start Date</BR>"}; # if (!$end_date){ # $error_msg2 = "The End Date Field is Blank. Please use Browser Ba +ck button and enter a Valid End Date</BR>"}; # if(!$error_msg) { #my $start_date_newfrmt = &date_format($start_date); my @date_array = split(/\//, $start_date); my $start_date_newfrmt = join('-', @date_array[2], @date_array[1], @da +te_array[0]); my @date_array1 = split(/\//, $end_date); my $end_date_newfrmt = join('-', @date_array1[2], @date_array1[1], @da +te_array1[0]); my @selected = param('Projects'); my $turned_on = param('verified_closed'); #print "Content-type: text/html\n\n"; #print $turned_on;

In reply to Adding dropdown Javascript Calendar to perl cgi by rakheek

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.