appendText.js

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).

Get Web Application Development with R Using Shiny - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.