hi

this is manjunath new to cgi, i have some cgi code, now i want to implement the same in javascript or jsp, please help me to do this. or please explain me what this code is doing.

here is the code:

$c = 1;
while(Allbase::FetchRow(\@d))
{
$d[2] = substr($d[2],0,10);
$d[3] = substr($d[3],0,10);
$d[4] = substr($d[4],0,10);
$d[5] = substr($d[5],0,10);
$d[10] = substr($d[10],0,50);
@nl = split(/_/,$d[11]);
$name = substr($nl[1],0,7);


$g1c = getcolor($d[6]);
$g2c = getcolor($d[7]);
$g3c = getcolor($d[8]);
$g4c = getcolor($d[9]);


# Chop it and pick the pname string
@ptags = split(/;/,$d[12]);
$pname = $d[12];
for $j (0..$#ptags)
{
if ($ptags[$j] =~ /(.*?)(p(.+?)(stsd|STSD|std))(.*)/)
{
$pname = $ptags[$j];
}
}
$pname =~ s/[wn](.+?)
#     $d[12] =~ s/(.*?)(p(.+?)(stsd|STSD))(.*)/$2/g;
#     $d[12] = $ptags[2];
print "<tr>
<td bgcolor='cyan'>$c</td>
type=Solution&id=$d[0]'>$d[0]</a></td>
<td>$d[1]</td>
<td bgcolor='white'>$pname</td>
<td bgcolor=$g1c>$d[2]</td>
<td bgcolor=$g2c>$d[3]</td>
<td bgcolor=$g3c>$d[4]</td>
<td bgcolor=$g4c>$d[5]</td>
<td bgcolor='white'>$name</td>
<td bgcolor='white'>$d[10]</td>
</tr>\n";
$c ++;
};
print "</table>\n";


}
else
{
Allbase::SQLError($msg);
printf "$msg\n";
}
Allbase::Release();
print $q->end_html;
sub getcolor
{
my $a = shift;
my $b = shift;
my $due = shift;



my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
= localtime(time);
$sun = time-(60*60*24*$wday);
$monday = $sun + (60*60*24);
$sunday = $monday + (60*60*24*6);
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
= localtime($sunday);
$this_sunday = sprintf("%4d-%02d-%02d",1900+$year,$mon+1,$mday);
$mon++;
if ($mon == 12)
{ $mon = 0;
$year++;
}
$next_first = sprintf("%4d-%02d-%02d",1900+$year,$mon,1);
print "<!-- $next_first -->\n";
my $col = 'white';
$col = 'lightgreen' if ($a =~ /^Met/);
$col = 'lightblue' if ($a =~ /^Late/);
$col = 'yellow' if (($a =~ /^Pending/) && ($b !~ /^Hold-Cust/) );
$col = 'orange' if (($a =~ /^Pending/) && ($b !~ /^Hold-Cust/) && ($due lt $next_first));
$col = 'magenta' if (($a =~ /^Pending/) && ($b !~ /^Hold-Cust/) && ($due le $this_sunday));
$col = 'red' if (($a =~ /^Not/) && ($b !~ /^Hold-Cust/));
$col = 'gray' if ($a =~ /^N\/A/);
return $col;
}


#($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
#   = localtime(time);
#$sun = time-(60*60*24*$wday);
#$monday = $sun + (60*60*24);
#$friday = $monday + (60*60*24*5);
#($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
#   = localtime($friday);
#$this_friday = (1900+$year).'-'.$mon+1.'-'.$mday;

That is too much code to try and explain what it all does.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.