In my javascript i want something like this
SomeFunction(attribute){
var prev_rating = {{ u_list.attribute }};
}
The function can have three different inputs... beauty, wealth, age
. So if I pass attribute = beauty
to the function, var prev_rating
should be set to
var prev_rating = {{ u_list.beauty }};
How can I achieve this ?
asked Aug 14, 2014 at 9:28
1 Answer 1
You have to write the value selection in Javascript:
var ratings = {beauty: {{u_list.beauty}}, wealth: {{u_list.wealth}}, age: {{u_list.age}} }
function SomeFunction(attribute) {
var prev_rating = ratings[attribute]
}
answered Aug 14, 2014 at 9:33
Comments
default