Add .on change function to js example so the code runs when the state se...

...lect is changed. Tested and working.