Skip to content

Instantly share code, notes, and snippets.

@dewski
Forked from atypical/ad
Created April 27, 2012 20:38
Show Gist options
  • Save dewski/2512858 to your computer and use it in GitHub Desktop.
Save dewski/2512858 to your computer and use it in GitHub Desktop.
ad
<!DOCTYPE html>
<html>
<head>
<title>Dope</title>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(function() {
var getPositions = function () {
return {
servo: $('#servo').val(),
position: $('#position').val()
}
};
$('#position, #servo').change(function() {
var positions = getPositions()
var url = "url/servo.php?servo=" + positions.servo + "&position=" + positions.position;
$.get(url)
})
$('#position').change(function() {
$(this).parent().find('span').text(getPositions().position)
})
$('#servo').change(function() {
$(this).parent().find('span').text(getPositions().servo)
})
})
</script>
</head>
<body>
<p>
Servo:
<input name="servo" id="servo" type="range" min="0" max="5" value="0" step="1" style="width:75%; margin:100px auto;">
<span>0</span>
</p>
<p>
Position:
<input name="position" id="position" type="range" min="0" max="180" value="0" step="1" style="width:75%; margin:100px auto;">
<span>0</span>
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment