<!DOCTYPE html>
<html>
<head>
<head>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/jquery-ui.min.js"></script>
<link href= "jqueryui/jquery-ui.css" rel="stylesheet" type="text/css" />
<script>
$(document).ready(function () {
$("#date").datepicker();
$("#slider1").slider({
max:1000,
min:0,
value: 0,
slide: function(event,ui){
$("#price").val(ui.value);
var valz = function(){
parseInt($("#banana").val())
}
if (valz() > $("#slider1").val()){
$("#banana").prop("checked",true);
}
}
});
$( "#price" ).change(function(){
$( "#slider1" ).slider("value", $(this).val())
$("#price").val($(this).val());
});
var fTotal = 0;
$('.fruit').click(function(){
if (this.checked){
fTotal += parseInt($(this).val());
$( "#slider1" ).slider("value", fTotal )
$("#price").val(fTotal);
}
else {
fTotal -= parseInt($(this).val());
$( "#slider1" ).slider("value", fTotal )
$("#price").val(fTotal);
};
});
});
</script>
</head>
<title>ProjectFreedom</title>
</head>
<body>
<div id = title>
<div><input type="text" id="date"></div>
<p>
<label for="price">Cost: £</label>
<input type="number" id="price" value="0" max="1000">
</p>
<div id="slider1"></div>
<form class="Fruit">
<input type="checkbox" id="banana" class="fruit" name="fruit" value= "25" >Banana<br>
<input type="checkbox" class="fruit" name="fruit" value="75">Apple<br>
<input type="checkbox" class="fruit" name="fruit" value="172">Melon<br>
<input type="checkbox" class="fruit" name="fruit" value="400">Leopard<br>
<input type="checkbox" class="fruit" name="fruit" value="328">Grimacing
</form>
Right, so I'm a bit stuck with this one. Very new to Javascript and programming but I've managed to concoct this for a project I'm working on.
Basically, I want the scroll bar value to add checks to the boxes based on the value, ie. when the scroll bar moves up, more and more checkboxes will become filled in. I'm trying to make it work for just one of the checkboxes (in this case banana) but I cannot seem to manage it. I've been working on it for hours and have done lots of research to get to this point but cannot go any further!!