Re: IMPORT TAG and Perl snippet

Joel Palmius <[email protected]> Fri, 15 Feb 2008 15:04:03 +0100 (CET)
Newsgroups gmane.comp.apache.mod-survey.general
Message-ID <[email protected]>
First, see my answer to the DBI post. I sent it just now. Maybe it will be 
easier for you to use that approach.

The problem you have is that the choice perl stuff happens before the 
import. You are using a pre-parse perl snippet (ie, happens before logic 
in document is interpreted), so this happens first. IMPORT is at display 
time, ie it happens when document is sent to browser, thus after document 
has been interpreted.

I'd suggestion you use the display dynamics instead of scripting it 
manually.

   [... IMPORT statement as you wrote it in your mail ...]

   <CHOICE NAME="test" CAPTION="{$vivfigl$}">
   ...


(The {$[variable]$} is for printing the session value SUBMITTED_[variable] 
at display time)

   // Joel


On Fri, 15 Feb 2008, Claudio Zilio wrote:

> Hi all,
>
> Is it possible to use a db imported variable inside a Perl snippet
> in the same page where IMPORT tag is?
>
> I've tried this.. but it doesn't work:
>
> <IMPORT DBIDSN="DBI:Pg:dbname=agoradb;host=127.0.0.1" DBIPASS=""
> DBITABLE="data.brumdoinfo" DBIUSER="postgres">
>    <VARIABLE FIELD="vivfigl"  NAME="vfigl" />
>    <FILTER CRITERIA="numint= {$numint$} AND codcom = {$codcom$}" />
> </IMPORT>
>
> <CHOICE NAME="inizio" CAPTION="{&
>
>    my($figl) = $session->getValue("SUBMITTED_vfigl");
>
>    print "vfigl " . $figl;
>
>    &}" MUSTANSWER="yes">
>        <CHOICEELEMENT VALUE="3" ACCESS="3" CAPTION="3: Figlio" />
>        <CHOICEELEMENT VALUE="4" ACCESS="4" CAPTION="4: Fratelli/Sorelle" />
> </CHOICE>
>
> Thanks
> Claudio
>
> Skickat av Claudio Zilio <[email protected]>
> till survey-discussion
>
Skickat av Joel Palmius <[email protected]>
till survey-discussion