kiloway54 has asked for the wisdom of the Perl Monks concerning the following question:

I'm new to Perl and having a problem with populating a textarea with the results of a query using tmpl_var.

The tmpl form:

<html> <form> <p><label for="id" >Record ID</label> <input id="id" value="<TMPL_VAR +name=id>" style="width:363px" ></p> <p><label for="dateOfIncident" >Date of Incident</label> <input id="da +teOfIncident" value="<TMPL_VAR name=dateOfIncident>" style="width:363 +px" ></p> <p><div><label for="descOfSymptoms">Description of Symptoms</label> <t +extarea id="descOfSymptoms" style="width:363px" rows="4" <TMPL_VAR de +scOfSymptoms> ></textarea></p> </form> </html>

The cgi script:

#!/usr/local/bin/perl use warnings; use strict; use CGI; use DBI; use HTML::Template; my $query = new CGI; my $id = $query->param('id'); my $db=DBI->connect( "dbi:Oracle:instance","user","password" ) || die( + $DBI::errstr . "\n"); my $SQL = "SELECT id, dateOfIncident, descOfSymptoms FROM KnownErrors +WHERE id='$id'"; my $sth=$db->prepare($SQL); $sth->execute(); my $template = HTML::Template->new(filename => '/usr/local/apache2/htd +ocs/test.tmpl'); while (my $results = $sth->fetchrow_arrayref) { $template->param(id => $results->[0]); $template->param(dateOfIncident => $results->[1]); $template->param(descOfSymptoms => $results->[2]); } print "Content-Type: text/html\n\n", $template->output;

The id and dateOfIncident populate with no problem. But I can't get the textarea to populate. If I change the textarea to a text box it populates just fine. For the textarea I've tried value="<TMPL_VAR descOfSymptoms>", name="<TMPL_VAR descOfSymptoms>", and no label: <TMPL_VAR descOfSymptoms>. All return nothing to textarea.

I'm working on Solaris 10 x86 in Vmware. Apache version is 2.3. Database is Oracle 10.2.0.2.

Replies are listed 'Best First'.
Re: HTML::Template and Textarea
by Anonymous Monk on May 02, 2011 at 06:37 UTC
Re: HTML::Template and Textarea
by tinita (Parson) on May 02, 2011 at 17:54 UTC
    additional comment: since the problem is the forgotten closing >, I suggest, whenever you have problems like that, first try to find out if the problem is the module or just a typo on your side. Just fill in dummy text instead of the template var. If that also doesn't appear you are a big step closer to your problem.