Ne vem kateri del kode bi bil bistveni za razjasnitev.
Pri spremembi kličem goFunc()
<input onchange="goFunc()" id="znes" name="znes" type="range" min=5000 max=500000 value=200000 step=1000 oninput="oznes(value)">
/----------------------------/
function goFunc() {
IzAnui(); // pripravi testne podatke (kasneje bo to na strežniku)
refi01(); // kliče PHP
drawChart(); // nariše graf
}
/----------------------------/
function refi01()
{
with (document.forms["f1"])
{
var curr = curr.value;
var _dnak = dnak.value;
var _znes = znes.value;
var _obme = obme.value;
var _leta = leta.value;
var str="http://localhost/moca/my-includes/mocaac.php";
str=str+"?poda="+curr+";";
str=str+dnak+";";
str=str+znes+";";
str=str+obme+";";
str=str+leta+"";
// document.write(str);
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4)
{
if (xmlhttp.status==200)
{
document.getElementById("txtHint1").innerHTML=xmlhttp.responseText;
}
}
}
xmlhttp.open("GET",str,true);
xmlhttp.send();
}
}
/----------------------------*/
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['', ''],
['Principal', exzn],
['Interest', exob]
]);
var options = {
pieHole: 0.4,
colors: ['#5D8BB7', '#721846', '#8CB85E',
'#A75EB8', '#B8A75E', '#5EB8A7',
'#0D3B67', '#660D3B', '#3B660D'],
legend: 'none',
slices: { 1: {offset: 0.1}}
};
var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
chart.draw(data, options);
}
/----------------------------/
Koda v PHP-ju kjer bi naj bil graf
<td rowspan="7" width="50%">Karkoli<div id="donutchart" style="width: 200px; height: 200px;"></div></td>
/----------------------------/
Koda na koncu osnovne strani, kjer pridejo podatki s strežnika.
<div id="txtHint1"></div>