Convert slider to external javascript -
hi have slider on page updates number using javascript. need put javascript out of html external js file. appreciated. sorry if explanation not clear. thanks.
<script> function outputupdate(n) { document.queryselector('.names').value = n; } </script> <form name="infonum"> <textarea rows="3" name="output" onclick="this.select()"></textarea><br /> <input type="button" class="button" value="go" onclick="populateform(this.form.names.value)"><br /> <input type=range class=rangeinput name="numnames" min=1 value=1 max=15 step=1 oninput="outputupdate(value)"><br /> <output for=rangeinput class=names>5</output> </form>
you need create new file myjsfile.js , paste code (inside tag). external java script files reference follows in html
<html> <head> <script type="text/javscript" src="myjsfile.js"></script> ....
js file
function outputupdate(n) { document.queryselector('.names').value = n; }
html
<html> <head> <script type="text/javscript" src="myjsfile.js"></script> </head> <body> <form name="infonum"> <textarea rows="3" name="output" onclick="this.select()"></textarea><br /> <input type="button" class="button" value="go" onclick="populateform(this.form.names.value)"><br /> <input type=range class=rangeinput name="numnames" min=1 value=1 max=15 step=1 oninput="outputupdate(value)"><br /> <output for=rangeinput class=names>5</output> </form> </body> </html>
Comments
Post a Comment