1

I want to do the following:

var table = new google.visualization.XXXXX(document.getElementById(divId));

where the X's represent a variable that is set previously.

Just so you know, I'm using Google visualizations here, but I don't think that is necessarily relevant to this question.

2 Answers 2

4

Use square bracket notation.

var XXXXX = "someString";
var table = new google.visualization[XXXXX](document.getElementById(divId));
Sign up to request clarification or add additional context in comments.

Comments

3

Pretty simple:

var table = new google.visualization[XXXXX](document.getElementById(divId));

Should do the trick.

1 Comment

That's wonderful, I really should have caught on to this earlier. Thanks, Robin and David.

Your Answer

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.