Hi, I would like a javascript script to be able to retrieve/update values given a user's input. Below is the example I'm currently running. In the post I have:
And in the script I have:
Now when I view the post the javascript does in fact run! It displays the slider, the submit button, and the number "23". This is all expected. However when I try sliding the slider, the number does not change. I put the submit button in to see if pressing that helps, and it does not. I believe this is because the javascript only runs when the page is loaded, not modified. Is there any way to do what I'm trying?
- Code:
<form>
<input type="range" value="23" min="0" max="1000">
<input type="submit" value="Submit">
<span id="TES"></span>
</form>
And in the script I have:
- Code:
$(function(){
if(document.getElementById('TES') != null){
var num = document.querySelector('input[type=range]').value;
document.getElementById('TES').innerHTML = ""+num+"";
}
});
Now when I view the post the javascript does in fact run! It displays the slider, the submit button, and the number "23". This is all expected. However when I try sliding the slider, the number does not change. I put the submit button in to see if pressing that helps, and it does not. I believe this is because the javascript only runs when the page is loaded, not modified. Is there any way to do what I'm trying?