Hello, I am trying to make it so that a user can choose which question they want to answer, and, using a textarea, answer that question. I'm having trouble figuring out how I can differentiate which question the user wants to answer. I've tried copying the html code for the textarea form into a variable, and then printing it foreach keys %hash, but I just wind up with syntax errors all over the place. My perl code takes each question in a separate .txt file and stores them into a hash in the form of question/answer pairs. If a question doesn't have an answer, the value is undef., I believe. Does anyone have any suggestions? I'm not asking for a direct answer, but rather some guidance from more experienced or insightful programmers. Any advice is appreciated. Thanks! Here is the most important code:

my @qa_list = ($pagev->listFile($anslist), $pagev->listFile($unanslis +t)); my %questions = map { split(/\t/, $_, 2) } @qa_list; my $answer = $cgi->param('answer'); print STDERR "$_ => $questions{$_}\n" foreach %questions; my $questionslist = join("<br>", @qa_list); my $aselect = $cgi->param('select');

Here is the assoicated HTML:

<html> <body> View and Answer Questions!<br> List of questions and answers:<br><br> ~questionslist~ <br><br> Which question would you like to answer? (1, 2, etc.) <form action="/home/megaoff/www/viewquestions.dhtml" method="p +ost"> Question #: <input type="text" name="select"/> <input type="submit" value="submit"/> <br><br> <form action="/home/megaoff/www/viewquestions.dhtml" method="p +ost"> Add an Answer: <br> <textarea rows="1" cols="50" name="answer"> Add an answer here </textarea> <input type="submit" value="submit"/> </form> </body> </html>
It's a little scattered right now, mostly because I'm still experimenting with things. But I hope the gist is there: Suggestions for differentiating which question the user wants to answer.

In reply to Executing perl script with html textarea by Bowlslaw

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.