I believe it should work if you try to access the object as an  
associative array...

var test = 'aa';
var myobj = someobj;
//you want to access something like myobj.{test+'_prefix'}
alert(myobj[test+'_prefix']);


[ Now playing: "Estrella Roja" by Panteón Rococó from "Panteón Rococó" ]

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