# make the multiple select
HTMLon() # switch to html mode
data(state)
HTMLselect("favoriteAmericanState", state.name, size=10, multiple='multiple', id="fstate") # generate the select box
After selecting one or more of the inputs in the select box, hit F9 or the calculate button and see that the following outputs change:
// This is a javascript block
// We manually extract the selected elements and create
// an R command vector that we subsequently send.
var el = dojo.byId("fstate");
var result = "fstate=c(";
for (i=0; i < el.length; i++) {
if (el.options[i].selected)
result = result + "'" + el.options[i].text + "',";
}
result = result + ")";
rpad.send("R", result); // note: do not make this the last command, or it chokes.
" "
# This is an R block to see if we updated ok in R
cat("fstate =\n")
fstate