javaandy
javaandy

Reputation: 205

Range slider change giving [object Object] error

Want the value of a range slider to display next to the slider. On the page roadtripsharing.com/map-it it is giving an [object Object] error however when i cut and paste the html and script into a snippet (below) it appears not to work at all, and throws an 'Unexpected end of input error.'

What am I doing wrong and how do I fix it?

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="range" min="0" max="100" value="33" id="rtsfader" style="display:inline-block">&nbsp;<output for="rtsfader" id="rtsmileage">33</output>&nbsp; miles
<script type="text/javascript">
function rtsoutputUpdate(vol) {
	document.querySelector('#rtsmileage').value = vol;
  console.log(vol); 
}
</script>

Upvotes: 0

Views: 125

Answers (1)

Aynolor
Aynolor

Reputation: 413

Actually, you don't need jQuery / JS. Just surround <input> and <output> with a <form> element.

<form oninput="rtsmileage.value = rtsfader.value">
      <input type="range" min="0" max="100" value="33" id="rtsfader" style="display:inline-block">&nbsp;<output for="rtsfader" id="rtsmileage">33</output>&nbsp; miles
<form>

Upvotes: 1

Related Questions