The JavaScript is very simple and looks like this:
<script type="text/javascript">
function buttonClick(){
var elem = document.getElementById('selection');
elem.innerHTML = document.getElementById('year').value;
}
</script>
You can see that we grab the element with the ID of selection and write the value of the year to it. You will, I am sure, wish to produce something a little more sophisticated than this! Now we have the basics, the second example is a bit more complex. In this example, we will be passing messages directly between server (R) and client (JavaScript).