[PLUG] Javascript question.

Jason Kirtland plug at lists.discorporate.us
Tue Sep 27 01:13:17 UTC 2005


David wrote:
>
> Does anyone know javascript?
> [...]
> In my environment I must use the name:
>                layer_status%5B1999%5D or layer_status[1999]
> [... however ...]
>                document.main.layer_status%5B1999%5D.value="PRECIP0";
> [...]
> BLOWS UP.

Javascript has an alternate object indexing syntax for this sort of 
situation:

  object['property'] = 'value';
  object.property = 'value'; // also valid

  document.main['layer_status[1999]'].value = 'foo';
  something['property with spaces'] = 'baz';

Also useful for variable indexing:

  next = array[++someIndex];
  p = 'quux'; return obj[p];

Best,
Jason




More information about the PLUG mailing list