I need help, please! I have a range input:
<input type="range" name="set_workers" class="set_workers" id="set_workers" min="0" max="10">
<input type="submit">
I have an ajax script run on page load getting some values. One of that values should be outputted over max range. So I want a range input with dynamic max value. Is there any way to do that? Should I echo a range in php to put it on ajax response? here is my ajax:
window.onload = function() {
var current_building = $('#building_name').val();
$.ajax(
{type: 'post',
url: '../account_handle/get_cost_upgrade.php',
data: {
building: current_building,
},
success: function (val){
$('#display_cost').html(val.test1);
$("#set_workers").attr("max", val.test2);
}
});
}
And the php code:
$sql = "SELECT * FROM $buildcost WHERE lvl = '$lvl'";
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_assoc($result);
$max_w = $row['max_w'];
echo json_encode(array(
"test1" => "doesn t matter",
"test2" =>
"$max_w"
));
I cutted some useless parts from php, php is not a problem, is working, same json, but i don t know how to put that value into max of range. Thanks all!