How to pass a parameter name in JavaScript?
<p>Is there a way to get a handler to a variable dynamically in JavaScript? I think this won't make sense so here's what I'm trying to do.</p>

<p>I'm using <a href="http://code.google.com/p/flot/" rel="nofollow">JQuery Flot</a> to generate graphs in my web app. Everything works fine until I have two graphs in the same page.   </p>

<p>I get the data from the database using c# and convert it into a JavaScript array and write onto the page like this.</p>

<p>HTML/C#:</p>

<pre><code>@{
        KII.Models.JsonPerformGraphData items = new KII.Models.JsonPerformGraphData();

        foreach (KII.Models.PerformanceGraphItem item in Model.PerformanceGraphItems)
        {
            items.Add(item);
        }

        &lt;script type="text/javascript"&gt;

      @Html.Raw("var pgdata"+Model.Id+" = ")  @Html.Raw(items.toJson()) ;

        &lt;/script&gt;
    } 
</code></pre>

<p>Then, I call a method on document ready to draw the graph</p>

<p>JavaScript:</p>

<pre><code>if ($(".PerformanceGraph")) {
        $(".PerformanceGraph").livequery(function () {
            //Display the graph for risk and reward.
            var options = { series: {
                bars: { show: true, barWidth: 0.45, align: "center" }
            },
                legend: {
                    show: true, position: "ne", backgroundOpacity: 0, container: $("#PerformanceGraphLegend")
                },
                multiplebars: true
            };


            var dataArray = $(this).attr('data-array');//I get the name of the variable as String.
            $.plot($(".PerformanceGraph"), pgdata, options);
        });
    } 
</code></pre>

<p><code>pgdata</code> from javascript must match <code>"var pgdata"+Model.Id+"</code> from HTML/C#. </p>

<p>How can I get the variable that the HTML/C# code spits out to the HTML?</p>
