Bowlslaw has asked for the wisdom of the Perl Monks concerning the following question:
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:
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.<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>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Executing perl script with html textarea
by space_monk (Chaplain) on May 21, 2013 at 17:08 UTC | |
|
Re: Executing perl script with html textarea
by Anonymous Monk on May 21, 2013 at 22:30 UTC | |
|
Re: Executing perl script with html textarea
by Anonymous Monk on May 22, 2013 at 22:39 UTC | |
|
Re: Executing perl script with html textarea
by Anonymous Monk on May 22, 2013 at 02:42 UTC |