[Chameleon] problem accessing HTML Hidden Variable

Paul Spencer pspencer at dmsolutions.ca
Fri Aug 5 07:39:28 EDT 2005


Actually, the first line *should* work.  PHP does do variable 
replacement inside strings like this.  It is very important to note, 
however, that this only happens inside strings delimited with double 
quotes like "this".  If you use single quotes like 'this' then variable 
replacement will not happen and the string will be interpretted 
literally.  In fact, it means that "this\n" will have a carriage return 
and 'this\n' will not have a carriage return.

To debug this, I would print_r($_GET); (or $_POST) in ParseURL to see if 
the submitted values actually contain what you expect.

Cheers

Paul

Jacob Delfos wrote:
> Hi Jan,
>  
> This line:
>  
> $szValue = " <INPUT TYPE=HIDDEN NAME=$szVariable VALUE=\"\">";
>  
> should be
>  
> $szValue = " <INPUT TYPE=HIDDEN NAME='".$szVariable."' VALUE=\"\">";
>  
> You actually included the variable reference as part of the string. So 
> $szVariable would not have been picked up as a variable name. Probably 
> if you check the source code of the page, you could see it being written 
> out as $szVariable. I also put some quotes.
>  
> regards,
>  
> Jacob
>  
>  
>  
> --------------------------------------------------------------------------------
> From: chameleon-bounces at lists.maptools.org 
> <mailto:chameleon-bounces at lists.maptools.org> 
> [mailto:chameleon-bounces at lists.maptools.org] On Behalf Of Jan Jansen
> Sent: 5 August 2005 00:05
> To: chameleon at lists.maptools.org <mailto:chameleon at lists.maptools.org>
> Subject: [Chameleon] problem accessing HTML Hidden Variable
>  
> 
> Hello list,
>  
> I have a problem accessing an HTML hidden variable in my wigdet. Please 
> can anyone tell me what I am missing here?
>  
> I include the custom Hidden variable as follows (this all works fine):
>  
> 
>  function GetHTMLHiddenVariables()
>     {
>       // parent::GetHTMLHiddenVariables();
>  
>         $szVariable = "CUR_PPC";
>         $szValue = " <INPUT TYPE=HIDDEN NAME=$szVariable VALUE=\"\">";
>         $aReturn[$szVariable] = $szValue;
>         return $aReturn;
>     }
>  
> *****
>  
> a javascript function on my template fills the hidden var with a value 
> (this all works fine):
>  
> ******
>  
>  /**
>      * get the javascript functions for this widget
>      */
>     function GetJavascriptFunctions()
>     {
>         $aReturn = array();
>         $szJsFunctionName = "zoom24ppc";
>         $szFunction = <<<EOT
> /**
>  * {$szJsFunctionName}
>  * called when the ppc value is set.
>  */
> function {$szJsFunctionName}(obj)
> {
>    
>  {$this->mszHTMLForm}.CUR_PPC.value = obj;
>  //alert({$this->mszHTMLForm}.CUR_PPC.value);
>    {$this->mszHTMLForm}.submit();
>        
>     return;
> }
> EOT;
>         $aReturn[$szJsFunctionName] = $szFunction;
>  
>         return $aReturn;
>     }
>  
> ******
>  
> But when I try to access the variable in ParseUrl function, it fails to 
> read out the value:
>  
> ******
>   function ParseURL()
>    {
>     // Check if HIDDEN input is set
>  
>         $szVariable = "CUR_PPC";
>        if ($this->isVarSet($szVariable))
>    {
>             $CURPPC = $this->getVar( "CUR_PPC" );
>  
> etc, etc.. What am I forgetting here? Any help would be highly appreciated
>  
> regards,
>  
> Jan
> <mailto:jacob.delfos at maunsell.com> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon

-- 
+-----------------------------------------------------------------+
|Paul Spencer                           pspencer at dmsolutions.ca   |
+-----------------------------------------------------------------+
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+


More information about the Chameleon mailing list