0
var chart;
var d = new Array();

function click() {
    d = document.getElementById('graph:hi').value;
    alert(d);
}
var c = new Array(66, 15, 2.5, 21.9, 25.2, 23.0, 22.6, 21.2, 19.3, 16.6, 14.8);
alert(c);
jQuery(document).ready(function (e) {
    chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container',
            defaultSeriesType: 'spline',
            ignoreHiddenSeries: false
        },
        title: {
            text: 'Height Report'
        },
        subtitle: {
            text: ''
        },
        xAxis: {
            categories: ['0', '0.5', '1.5', '2.5', '3.5', '4.5', '5.5', '6.5', '7.5', '8.5', '9.5', '10.5', '11.5', '12.5', '13.5', '14.5', '15.5', '16.5', '17.5', '18.5', '19.5', '20.5', '21.5', '22.5', '23.5', '24.5', '25.5', '26.5', '27.5', '28.5', '29.5', '30.5', '31.5', '32.5', '33.5', '34.5', '35.5']
        },
        yAxis: {
            title: {
                text: 'Percentage'
            },
            labels: {
                formatter: function () {
                    return this.value + '%';
                }
            }
        },
        tooltip: {
            formatter: function () {
                return '' + this.x + ': ' + this.y;
            }
        },
        plotOptions: {
            spline: {
                marker: {
                    radius: 3,
                    lineColor: '#666666',
                    lineWidth: 1
                }
            }
        },
        series: [{
            name: 'Pecentile 3',
            data: c
        }, {
            name: 'Pecentile 10',
            data: d
        }]
    });
});

from XHTML i get regularvalue and getted in click() function. jQuery(document).ready(function(e){}) is a graph plotting code..i want to pass d value from click() to jquery function.but i can't get the values in jquery function.thank you

2
  • What is calling this function called click? Commented May 26, 2012 at 10:23
  • i called the inputText field values from xhtml...onloading i call this click() function Commented May 26, 2012 at 10:38

1 Answer 1

2

Your code is conceptually weirdly written.

Why do you execute some code before the document is ready and some code inside the jQuery(document).ready(); ??

If you put everything inside the latter function, with the proper modifications, averything can work.

I suggest to:

  1. insert everything into the Query(document).ready(); function
  2. instead of using the function click(...) I would use a more jquery style, that is to say: $('graph:hi').click(function(){WRITE THE CODE});

  3. when you do this, d will b a global var inside your scope, so you will not have the problem you are experiencing

Sign up to request clarification or add additional context in comments.

3 Comments

Repped. Agreed. The poster should be encouraged to re-write, good advice; those vars will become global inside the DOM jQuery.
be sure that the global syntax is well written. Also: did you include jquery into your html code? For instance with <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
I can't help you this way, please post your code as an update and I can then check it.

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.