Hi.
I need to know how to display the data in the following format for each question on the form as well as how many 'votes' each of the four choices received:
I think pasta is good |
Strongly agree | ******** |
Agree | ** |
Disagree | ************* |
Strongly disagree | **** |
The asterisks would represent the red bar which is a graphical measure of each hash value. I could post the html form if need be.
Thanks,
-Katie
| [reply] |
PerlMonks messes up the first table, so it's in code tags.
I also had HTML::BarGraph laying around, but I never use it, so no example ;)
use HTML::BarChart;
use CGI qw[ *table Tr td br Th ];
my $survey = 'I think pasta is good';
my %survey = (
'Strongly agree' => '********',
'Agree' => '**',
'Disagree' => '*************',
'Strongly disagree' => '****'
);
my $flippy = 0;
my $Chart = HTML::BarChart->new( $survey, 100, 100 );
foreach my $key ( keys %survey ) {
$Chart->bar(
$key,
length $survey{$key},
$flippy
? $flippy++ && "red"
: $flippy-- && "black"
);
}
$Chart->draw;
print start_table({-border=>1}),Th({-colspan=>2}, $survey );
foreach my $key ( keys %survey ) {
print Tr(
td({ -height => "30", -bgcolor => "red" },$key),
td($survey{$key} )
);
}
print end_table;
__END__
<table bgcolor="#000000" width="100" height="100" border="0" cellp
+adding="0" cellspacing="1"><tr>
<td colspan="5">
<table border="0" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF
+" width="100%">
<tr><td valign="top" align="center"><font size="2" face="Arial">
I think pasta is good
</td></tr></table>
</td></tr><tr><td colspan="5" align="center"><table bgcolor="#FFFFFF"
+border="0" cellpadding="0" cellspacing="0" width="100%"><tr>
<td valign="bottom" align="center" width="100">
<table height="30.7692307692308" width="25" bgcolor="0" cellpa
+dding="1" cellspacing="1">
<tr><td></tr></td></table>
</td>
<td valign="bottom" align="center" width="100">
<table height="100" width="25" bgcolor="red" cellpadding="1" c
+ellspacing="1">
<tr><td></tr></td></table>
</td>
<td valign="bottom" align="center" width="100">
<table height="15.3846153846154" width="25" bgcolor="0" cellpa
+dding="1" cellspacing="1">
<tr><td></tr></td></table>
</td>
<td valign="bottom" align="center" width="100">
<table height="61.5384615384615" width="25" bgcolor="red" cell
+padding="1" cellspacing="1">
<tr><td></tr></td></table>
</td>
</tr></table></td></tr><tr><td><table width="100%" border="0" cellpadd
+ing="0" cellspacing="1" bgcolor="#FFFFFF"><tr>
<td align="center"><font size="1" face="Arial">Strongly disagree</
+font></td></tr></table></td>
<td><table width="100%" border="0" cellpadding="0" cellspacing="1" bgc
+olor="#FFFFFF"><tr>
<td align="center"><font size="1" face="Arial">Disagree</font></td
+></tr></table></td>
<td><table width="100%" border="0" cellpadding="0" cellspacing="1" bgc
+olor="#FFFFFF"><tr>
<td align="center"><font size="1" face="Arial">Agree</font></td></
+tr></table></td>
<td><table width="100%" border="0" cellpadding="0" cellspacing="1" bgc
+olor="#FFFFFF"><tr>
<td align="center"><font size="1" face="Arial">Strongly agree</fon
+t></td></tr></table></td>
</tr></table>
I think pasta is good | Strongly disagree | **** | Disagree | ************* | Agree | ** | Strongly agree | ******** |
MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" | I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). | ** The third rule of perl club is a statement of fact: pod is sexy. |
| [reply] [d/l] |
<table border="1">
<tr>
<td width="40%" align="right">QUESTION_TEXT</td>
<td width="60%">
<table width="20" cellspacing="0" cellpadding="5" border="0
+">
<tr bgcolor="red"><td align="center"><strong>20</strong
+></td></tr>
</table>
</td>
</tr>
<tr>
<td width="40%" align="right">QUESTION_TEXT</td>
<td width="60%">
<table width="30" cellspacing="0" cellpadding="5" border="0
+">
<tr bgcolor="red"><td align="center"><strong>30</strong
+></td></tr>
</table>
</td>
</tr>
<tr>
<td width="40%" align="right">QUESTION_TEXT</td>
<td width="60%">
<table width="40" cellspacing="0" cellpadding="5" border="0
+">
<tr bgcolor="red"><td align="center"><strong>40</strong
+></td></tr>
</table>
</td>
</tr>
<tr>
<td width="40%" align="right">QUESTION_TEXT</td>
<td width="60%">
<table width="50" cellspacing="0" cellpadding="5" border="0
+">
<tr bgcolor="red"><td align="center"><strong>50</strong
+></td></tr>
</table>
</td>
</tr>
</table>
Try this HTML in your browser. Are you looking for something like that?
--dda | [reply] [d/l] |
HOW TO CODE AN OPINION POLL WITH MYSQL AS BACKEND
i am using Message Master as a platform for Cellphones. I code on Perl and the database is MYSQL. the arguments to be taken are.
YES;No;Time;CellNumber;counter
| [reply] |