This isn't really passing values. It's just calling a function when you press a button:
$(document).ready(function() {
$('form').on('submit', function(e) {
e.preventDefault(); // we don't want to submit the form
$('#piechart').each(function() { // only do this if the element is found
// clear the canvas
this.getContext('2d').clearRect(0, 0, this.width, this.height);
});
var angles = [
$('#angle1').val() || 0,
$('#angle2').val() || 0,
$('#angle3').val() || 0
];
piechart("piechart1", ["cyan", "yellow", "green"], angles);
});
});
val()
gets the value of the input
element. We do || 0
to set it to 0
just in case the browser doesn't understand type="number"
and sends us an empty string.