use of a Perl variable in added HTML code show only the variable name

English! place to talk about development, programming and coding
Post Reply
nicmic
Znuny newbie
Posts: 7
Joined: 31 Jan 2015, 15:23
Znuny Version: 4.0.5

use of a Perl variable in added HTML code show only the variable name

Post by nicmic »

I have added a textarea field to the sidebar with a output filter module. As long as good.
Sadly i'm more experienced with c++ and js and so its a fight with Perl as beginner.

Code: Select all

my $txt = "test";
 
#add new textarea
my $sbTextArea= q~
 <textarea id="info" data-id = $txt ></textarea>
~;

${$Param{Data}} =~ s{(<...>)}{$1$sbTextArea};
At the moment i have no idea how i can use the Perl variables in the HTML code.
The data-id will be showed as "$txt" and not with value test?
tto
Znuny wizard
Posts: 315
Joined: 09 Jan 2007, 15:24
Znuny Version: OTRS 5.0.x
Real Name: Torsten
Company: c.a.p.e. IT GmbH
Location: Chemnitz
Contact:

Re: use of a Perl variable in added HTML code show only the variable name

Post by tto »

nicmic wrote:I have added a textarea field to the sidebar with a output filter module. As long as good.
Sadly i'm more experienced with c++ and js and so its a fight with Perl as beginner.

Code: Select all

my $txt = "test";
 
#add new textarea
my $sbTextArea= q~
 <textarea id="info" data-id = $txt ></textarea>
~;
if you do not want $txt to be shown as '$txt' but as the content of the variable, don't use the q-notation. Of course, there's more than one way to do it, just two samples:

Code: Select all

 my $sbTextArea= '<textarea id="info" data-id =" '.$txt.'" ></textarea>'; 
..or..

Code: Select all

 my $sbTextArea= "<textarea id=\"info\" data-id = \"$txt\"></textarea>"; 
... or others.

PS: I added missing quotation marks in data-ids value assignment - this has nothing to do with your Perl-issue :-)

regards, T.
--
KIX 17.x (fork of OTRS)
Professional KIX-, or OTRS-integration, development and consulting by c.a.p.e. IT - http://www.cape-it.de
For questions and hints regarding KIX(4OTRS) please go to https://forum.kixdesk.com/
Bei Fragen und Hinweisen zu KIX(4OTRS) bitte an https://forum.kixdesk.com/ wenden.
nicmic
Znuny newbie
Posts: 7
Joined: 31 Jan 2015, 15:23
Znuny Version: 4.0.5

Re: use of a Perl variable in added HTML code show only the variable name

Post by nicmic »

Ok, used instead the q notation the single quotes + "'.txt.'" and this works. Thank you.
Post Reply