-1

Ok. The code here is in fact Javascript but I can not find a way to fixing the problem in javascript. The code below is javascript.

var =inputdata; 
dataout = data.items.inputdata.time 

This is how it would sort of look like if it was php

dataout = data.items.$inputdata.time

I would like inputdata to be treated as a variable and not as text. Sorry for the small amount detail

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
  • 2
    `var =inputdata;` is invalid syntax. – Sebastian Simon Mar 29 '16 at 15:18
  • I know its = something else above – James Coombes XD Mar 29 '16 at 15:34
  • *"This is how it would sort of look like if it was php"* In PHP, `.` is the concatenation operator. `data` and `items` would be constants. Do you really want to concatenate the value of `data` with the value of `items`? E.g. if `data = 'foo'` and `items = 'bar'` do you want the result to be `'foobar'`? – Felix Kling Mar 29 '16 at 15:36

1 Answers1

1

You can use square bracket notation:

dataout = data.items[inputdata].time 

This will allow you to use a string in place of a key for a javascript object.

millerbr
  • 2,951
  • 1
  • 14
  • 25