hi,
Anyone know how I can set the value attribute to “5” and display it as “5 days” on load.
If I inspect the element and drag and release the handle I will see the value attribute updated with the correct number. However when I load the page and inspect before dragging, there is no value attribute, and it seems like the default value won’t be submitted if the attribute is not set.
html
<form action="step.php" method="post">
<div class="slider-wrapper">
<div class="slider" id="slider3"></div>
<input name="amount" type="text" id="amount" class="amount" readonly>
</div>
<button type="submit">Ok!</button>
</form>
jquery
$(function() {
$( "#slider" ).slider({
value: 5,
min: 1,
max: 30,
slide: function( event, ui ) {
$( "#amount" ).val( ui.value + ' days' );
},
change: function( event, ui ) {
$( '#amount' ).attr('value', ui.value);
}
});
});