Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Writing an opinion poll in perl.

by Jaap (Curate)
on Sep 20, 2003 at 09:38 UTC ( [id://292832]=note: print w/replies, xml ) Need Help??


in reply to Writing an opinion poll in perl.

And what is your question?

Replies are listed 'Best First'.
Re: Re: Writing an opinion poll in perl.
by DigitalKitty (Parson) on Sep 20, 2003 at 09:58 UTC
    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
      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.

      <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

      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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://292832]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2025-04-25 15:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.