Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: I need a help! regarding with SELECT html with Perl

by GrandFather (Sage)
on Sep 20, 2012 at 21:47 UTC ( #994765=note: print w/ replies, xml ) Need Help??


in reply to I need a help! regarding with SELECT html with Perl

Take a look at HTML::Template. It has the potential to make your life much easier. Consider:

use strict; use warnings; use HTML::Template qw(); my $tmplStr = <<TMPL; <tr class='<TMPL_VAR name="className">'> <TMPL_LOOP name="pictures"> <td onmouseout='showPicture("<TMPL_VAR +name="file">",0, "<TMPL_VAR name="path">")' onmouseover='showPicture("<TMPL_VAR name="file">",1, "<TMPL_VA +R name="path">")' ><TMPL_VAR name="file"></td> </TMPL_LOOP></tr> TMPL my $tmpl = HTML::Template->new(scalarRef => \$tmplStr); my @pictures = ( {file => 'wibble.jpg', path => '/here/there/everywhere'} +, {file => 'wobble.jpg', path => '/here/there/everywhere'} +, {file => 'floop.jpg', path => '/here/there/elsewhere'}, ); $tmpl->param( className => 'pinkAsAnything', pictures => \@pictures, ); print $tmpl->output();

Prints:

<tr class='pinkAsAnything'> <td onmouseout='showPicture("wibble.jpg",0, "/here/there/everywher +e")' onmouseover='showPicture("wibble.jpg",1, "/here/there/everywhe +re")' >wibble.jpg</td> <td onmouseout='showPicture("wobble.jpg",0, "/here/there/everywher +e")' onmouseover='showPicture("wobble.jpg",1, "/here/there/everywhe +re")' >wobble.jpg</td> <td onmouseout='showPicture("floop.jpg",0, "/here/there/elsewhere" +)' onmouseover='showPicture("floop.jpg",1, "/here/there/elsewhere +")' >floop.jpg</td> </tr>

which isn't the answer you thought you were looking for, but should head you in a useful direction. Note that you can load the template HTML from a file instead of a string so the HTML becomes independent of your script to make maintnance of both clearer and easier.

True laziness is hard work


Comment on Re: I need a help! regarding with SELECT html with Perl
Select or Download Code
Replies are listed 'Best First'.
Re^2: I need a help! regarding with SELECT html with Perl
by huchister (Acolyte) on Sep 28, 2012 at 13:14 UTC
    Thanks, I didn't solved problem this way, but looks a lot lot easier than what I have wrote. I shall take a look at template also. However I made a function that receive array of selected value, while loop to sort out which one to sent or not. Have nice day!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (17)
As of 2015-07-28 18:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls