0

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

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.