RV: [Chameleon] Custom Widget, read value of input text in Draw Publish

Ines mleonsoft at yahoo.com.ar
Thu Feb 1 10:48:44 EST 2007


Yes, is the same. I worked with 2 variables to try ('espe' and 'especie'). I
simplified the code again to work with just one variable ('especie'). I used
'espe' to take the value of 'especie' in DrawPublish(), and then use 'espe'
in ParseURL()
function DrawPublish()
    {
        // init vars
        $szReturn = "<font color='#000000' size='2' face='Arial, Helvetica,
sans-serif'>Search by scientific name </font><input type='text'
name='especie' > ";
     $this->espe= $this->getVar('especie'); ----------------------- HERE
.............................................

But I doesn´t work.
For that reason, I simplified the code again and I work with just one
variable ('especie', the name of the input text) directly in ParseURL().
isVarSet in ParseURL() returns 0 (zero) ever and the content of $this->lb is
ever "no":

function DrawPublish()
    {
        // init vars
        $szReturn = "<font color='#000000' size='2' face='Arial, Helvetica,
sans-serif'>Search by scientific name </font><input type='text'
name='especie'>        ";
        // execute parent
        $szReturn .= parent::DrawPublish();
        // return
        return $szReturn;
    }

function  ParseURL()
    {
        // execute parent function
        parent::ParseURL();

if ( $this->isVarSet( "NAV_CMD" ) &&
                            $this->getVar( "NAV_CMD" ) == 'UUW' )
{
	$this->x = -85;
	$this->y = 13;
	if ( $this->mszCoords == 'aa')
	{
		if ($this->isVarSet('especie') == 0) -------------->RETURN 0 EVER
		{
			$this->lb = "no";
		}
		else
		{
			$this->lb = $this->getVar('especie');
		}
		$poLayer = $this->moMapObject->oMap->getLayerByName('pointlatlon');
		$poLayer->set("status", MS_ON);
		$pt = ms_newPointObj();
   		$ln = ms_newLineObj();
		$shp = ms_newShapeObj(MS_SHAPE_POINT);
		$shp->set("text", $this->lb);-------------------------> CONTENT= "no"
   		$pt->setXY($this->x,$this->y);
    	$ln->add($pt);
    	$shp->add($ln);
    	$poLayer->addFeature($shp);


	}
Thank you again
Ines

-----Mensaje original-----
De: Julien-Samuel Lacroix [mailto:jlacroix at mapgears.com]
Enviado el: jueves, 01 de febrero de 2007 12:23
Para: Ines
CC: chameleon at lists.maptools.org
Asunto: Re: RV: [Chameleon] Custom Widget, read value of input text in
Draw Publish


Hi,
Is it possible that this code is not the same as you shared with us
before? The if() statement in the widget you shared with us last week was:

if ($this->isVarSet('espe') == 0)
{
     $this->lb = "no";
}
else
{
     $this->lb = $this->getVar('espe');
}

Everything worked fine when I changed it for:
if ($this->isVarSet('especie') == 0)
{
     $this->lb = "no";
}
else
{
     $this->lb = $this->getVar('especie');
}

Is it the same for you?

Julien


Ines wrote:
> Hello, I tried to read the variable but the widget don't take the value of
> the input text.
> I have just one input text box and the button of the wiget.
> First, I write some text in te input text box. Example: hello
> Second, I click the buttom of the widget, but the widget don´t read the
> value of my input text box (hello). The name of my input is
'especie'(<input
> type='text' name='especie'>).
>
> I use isVarSet and getVar, but it don´t works. I think the widget don´t
take
> the name of the input text ('especie') like a variable. I defined
'especie'
> en the class UUW: var $especie;
>
> I have defined the input text in DrawPublish() and I'm trying to read the
> variable in the parseURL()
>
> function DrawPublish()
>     {
>         // init vars
>         $szReturn = "<font color='#000000' size='2' face='Arial,
Helvetica,
> sans-serif'>Search by scientific name </font><input type='text'
> name='especie'>        ";
>         // execute parent
>         $szReturn .= parent::DrawPublish();
>         // return
>         return $szReturn;
>     }
> ---------------------------------------------------
>
> function  ParseURL()
>     {
>         // execute parent function
>         parent::ParseURL();
>
> if ( $this->isVarSet( "NAV_CMD" ) &&
>                             $this->getVar( "NAV_CMD" ) == 'UUW' )
> {
> 	$this->x = -85;
> 	$this->y = 13;
> 	if ( $this->mszCoords == 'aa')
> 	{
> 		if ($this->isVarSet('especie') == 0) -------------->RETURN 0 EVER
> 		{
> 			$this->lb = "no";
> 		}
> 		else
> 		{
> 			$this->lb = $this->getVar('especie');
> 		}
> 		$poLayer = $this->moMapObject->oMap->getLayerByName('pointlatlon');
> 		$poLayer->set("status", MS_ON);
> 		$pt = ms_newPointObj();
>    		$ln = ms_newLineObj();
> 		$shp = ms_newShapeObj(MS_SHAPE_POINT);
> 		$shp->set("text", $this->lb);-------------------------> CONTENT= "no"
>    		$pt->setXY($this->x,$this->y);
>     	$ln->add($pt);
>     	$shp->add($ln);
>     	$poLayer->addFeature($shp);
>
>
> 	}
>
>
> }
>
>         // return success
>         return true;
>     }
>
> Do I have to do something more for take the value of the variable?
> Thank again
> Ines
>
>


--
Julien-Samuel Lacroix
Mapgears
http://www.mapgears.com/



More information about the Chameleon mailing list