In JS It'd probably be something like:

writeJS = function(prefix) {

   // databaseresult.main_fade = 'whatever';
   // databaseresult.lightbox_fade = 'whatever';

   if (databaseresult[prefix + '_fade'] == 1) {
     // do whatever
   }

}

---------------------------------------------------
Keri Henare

[e]    [email protected]
[m]    021 874 552
[w]    www.kerihenare.com

On 13/01/2009, at 11:22 AM, matt_thomson wrote:

>
> Thanks, ${//make you var name here} makes my life a lot easier, does
> anyone know if this can be done in javascript?
>
> On Jan 13, 11:02 am, Alexei Tenitski <[email protected]> wrote:
>> use $databaseresult->{$prefix.'_fade'}
>>
>> On 13/01/2009 10:54, matt_thomson wrote:
>>
>>> Does anyone know if this is possible?
>>
>>> //$prefix equals 'main' or 'lightbox', both strings
>>> function writeJs($prefix)
>>> {
>>>    //if the function is called with 'main' as the
>>>    //prefix, I want to check the
>>>    //var $databaseresult->main_fade, if
>>>    //'lightbox' is the prefix, I want to check the
>>>    //var $databaseresult->lightbox_fade
>>
>>>        //this will throw an error, but it shows what I mean
>>>         if($databaseresult->.$prefix.'_fade' == 1)
>>>    {
>>>            //write some js for the main gallery
>>>            //or lightbox gallery
>>>    }
>>> }
>>> //I call this function twice, once to write some js for a gallery,
>>> //and another time to write some similar js for the lightbox bit
>>
>>> Thanks,
>>
>>> Matt.
> >


--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---

Reply via email to