[Chameleon] java script variables

Abbott,Arthur Arthur.Abbott at nscc.ca
Wed May 17 13:48:19 EDT 2006


Allright I'll try that.  In order to do that I have to use:
 
    function GetJavascriptVariables()
    {
        // init vars
        $aReturn = parent::GetJavascriptVariables();
        $aReturn['NewUrl'] = "http://*.*.*.*/images/softball.png";
        
        // return
        return $aReturn;
 
in the widget correct?  I take it that the variable must be declared in the template.html file? and hopefully lastly, how is it used within queryresults?
 
Arthur
 
>Hi,
>Sorry I did not thought you were using AJAX. You should then use
>javascript variables. If you add javascript code like this, you can
>access javascript variables in the main window (not tested):
>
>window.opener.javacript_variable = 'junk';
>
>Can it do the trick?
>
>Best regards,
>Julien
>
>Abbott,Arthur wrote:
> Again thanks for the reply,
>
> The reason I wasnt seeing the updated session variable is that it seems that the session variable only updates on a page
>refresh.  Unfortunately, I'm using AJAX, so the page is not refreshing like it would normally. Thus the session variable does
>not update. When I disabled AJAX, the value showed up. The side effect is that once i update the <img> src, the page 
>refreshes and the original image is once again displayed.
>
> Is there a way to refresh the session variable without refreshing the page? I really need to keep the AJAX code...
>
> thanks in advance,
>
> Arthur
>
>
>>Hi,
>>First make sure that your code that assign value in the $_SESSION array
>>is after the serie of include_once() at the beginning of the file.
>>
>>Then in the Query.widget.php, in the ParseURL() function, try to do:
>>echo $_SESSION['junk'];
>>
>>You will see if the value is set or not. Note that the main page have to
>>reset somehow to re-process the widget. Is it the case?
>>
>>Julien
>>
>>Abbott,Arthur wrote:
>>Ok, I switched over to using a $SESSION variable. Unfortunately I have the same behaviour. When I try to use the value in QueryWidget that was supposed to be set in QueryResults, the value does not change. This is wierd since i know its changing in QueryResult. I echoed the value before and after and the value does change.
>>
>>  echo $_SESSION['junk'];
>>  $_SESSION['junk'] = $url;
>>  echo $_SESSION['junk'];
>>
>>Using this code, the value of session is changed and i can see the change, yet when im in QueryWidget I dont see the new value.
>>
>>I wonder, am i trying to use the variable in the wrong place? I am currently trying to use the value inside of the QueryWMouseClick function of QueryWidget. should I be trying to use it someplace else?
>>
>>Arthur
>>
>>
>>
>>
>>
>>>Hi,
>>>Since QueryResults.phtml is a script beside Chameleon (not in it), it is
>>>called in a different window. So the GLOBALS won't work. You need to use
>>>the $SESSION variables instead.
>>>
>>>Julien
>>>
>>>Abbott,Arthur wrote:
>>>Everyone,
>>>
>>>I'm currently working with the query widget I have code that finds a value within a shape file. This code
>>>is in QueryResult.phtml. I would like to pass the value back to Query.Widget.php. I thought about using
>>>global variables.
>>>
>>>I've placed the value in the $GLOBALS array inside QueryResult. When I'm back in Query.Widget the value is unchanged...
>>>
>>>I set the value in QueryResult with the line:               $GLOBALS['gblurl'] = $url;
>>>
>>>When I look at the value outside of QueryResult the value does not contain the value it should.  Am I looking at
>>>it in the wrong place? I'm currently examining the global at the end of the function that does the popup for the
>>>query widget...
>>>
>>>function {$szJsFunctionName}(e)
>>>{
>>>   if ({$this->mszHTMLForm}.NAV_CMD.value != "{$this->mszCmd}")
>>>       return true;
>>>   
>>>   MapWgetMouse(e);
>>>   if ( !MapWinsideMap() )
>>>       return true;
>>>   nX = {$this->mszHTMLForm}.MAP_CURSOR_POS_X.value;
>>>   nY = {$this->mszHTMLForm}.MAP_CURSOR_POS_Y.value;
>>>   szNav = "NAV_INPUT_COORDINATES=" + nX + "," + nY;
>>>
>>>   if ({$szPopupResults})
>>>   {
>>>       szPopupURL = "{$szPopupURL}";
>>>       szPopupName = "{$szPopupName}";
>>>       szPopupOptions = "{$szPopupOptions}";
>>>       szPopupURL = szPopupURL + "&" + szNav;
>>>       window.open( szPopupURL, szPopupName, szPopupOptions );
>>>   }
>>>   if ({$szHighlightResults})
>>>   {
>>>       var queryCoords = nX + "," + nY;
>>>       var img = CWCDHTML_GetImage( 'MapLayerDivImg' );
>>>       img.src = gMapDHTMLURL + "&run_query=1&gszQueryCoords=" + queryCoords + "&gszPersistentQuery={$szPersistentResults}";
>>>       window.status = img.src;
>>>   }
>>>   if ("{$this->mszIFrameName}" != "" )
>>>   {
>>>       szPopupURL = "{$szPopupURL}";
>>>       szPopupURL = szPopupURL + "&" + szNav;
>>>       window.frames['{$this->mszIFrameName}'].location.href = szPopupURL + "&run_query=1";
>>>   }
>>>   if ({$szSubmitPage})
>>>   {
>>>       {$this->mszHTMLForm}.submit();
>>>   }
>>>   goEventManager.triggerEvent( 'ON_QUERY', nX, nY );
>>>
>>>   //Examine the contents of global value set in QueryResult
>>>   alert("{$GLOBALS['gblurl']}")
>>>
>>>   return true;
>>>}
>>>
>>>If anybody has an idea as to why the value is not updating, it would be greatly appreciated,
>>>
>>>Arthur
>>>
>>>_______________________________________________
>>>Chameleon mailing list
>>>Chameleon at lists.maptools.org
>>>http://lists.maptools.org/mailman/listinfo/chameleon <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://lists.maptools.org/mailman/listinfo/chameleon>  <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://lists.maptools.org/mailman/listinfo/chameleon <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://lists.maptools.org/mailman/listinfo/chameleon> >  <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://lists.maptools.org/mailman/listinfo/chameleon > >
>>
>>
>>--
>>Julien-Samuel Lacroix
>>Mapgears
>> <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://lists.maptools.org/mailman/listinfo/chameleon%20%3Chttps://webmail.nscc.ca/exchweb/bin/redir.asp?URL=https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://lists.maptools.org/mailman/listinfo/chameleon> http://www.mapgears.com/ <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://www.mapgears.com/>  <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://www.mapgears.com/ <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://www.mapgears.com/> >  <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://www.mapgears.com/ > >
>>
>>
>>
>>_______________________________________________
>>Chameleon mailing list
>>Chameleon at lists.maptools.org
>> <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://www.mapgears.com/%20%3Chttps://webmail.nscc.ca/exchweb/bin/redir.asp?URL=https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://www.mapgears.com/> http://lists.maptools.org/mailman/listinfo/chameleon <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://lists.maptools.org/mailman/listinfo/chameleon>  <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://lists.maptools.org/mailman/listinfo/chameleon <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://lists.maptools.org/mailman/listinfo/chameleon> >
>
>
> --
> Julien-Samuel Lacroix
> Mapgears
> http://www.mapgears.com/ <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://www.mapgears.com/>  <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://www.mapgears.com/ <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://www.mapgears.com/> >
>
>
>
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://lists.maptools.org/mailman/listinfo/chameleon> 

--
Julien-Samuel Lacroix
Mapgears
http://www.mapgears <https://webmail.nscc.ca/exchweb/bin/redir.asp?URL=http://www.mapgears.com/> 



More information about the Chameleon mailing list