Reputation: 1
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
Upvotes: 0
Views: 997
Reputation: 3125
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:
Query(document).ready();
functioninstead of using the function click(...)
I would use a more jquery style, that is to say: $('graph:hi').click(function(){WRITE THE CODE});
when you do this, d will b a global var inside your scope, so you will not have the problem you are experiencing
Upvotes: 2