Good morning: I have a variable that contains an example number $ por_disfrutar = 4; And then with a select I do a for cycle to go through those 4 numbers and I throw the following:
<?php
for ($i=1; $i <=$por_disfrutar ; $i++) {
echo "<option value=".$i.">".$i."</option>";
$n=$n+1;}
?>
And later what I need is that according to the number that I choose in the Select (example I select the number 2) it only allows me to pick up the dates in my Jquery calendar according to the number that I choose in the Select and the rest disables me if I try to pick one more
Please help me with this code because I am a vile newbie in the use of Jquery and I am learning. It is to validate to assign the MaxPicker the value of the number selected in the Select.
Select the days
$ (document) .ready (function () { console.log ("ready!"); var selected = $ ('# dias option: selected'); var value = selected.val (); $ ('# id3'). multiDatesPicker ({ dateFormat: "dd-mm-yy", maxPicks: value }); });
$( document ).ready(function() {
console.log( "ready!" );
var selected = $('#dias option:selected');
var value=selected.val();
$('#id3').multiDatesPicker({
dateFormat: "dd-mm-yy",
maxPicks: value
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<?php
$por_disfrutar=4;
?>
<div class="form-group row">
<label for="dias_solicitar"class="col-xs-12 col-sm-6 col-md-2 col-form-label">Dias a solicitar </label>
<div class="col-md-2">
<select id="dias" name="dias">
<?php
//Tu variable.
for ($i=1; $i <=$por_disfrutar; $i++) {
echo "<option value=".$i.">".$i."</option>";
$n=$n+1;
}
?>
</select>
</div>
<label for="dias_solicitar"class="col-xs-12 col-sm-6 col-md-2 col-form-label">Selecciona los dias </label>
<div class="col-md-6"><input id="id3" type="text"/></div>
<link rel="stylesheet" type="text/css" href="pruebas/css/jquery-ui.css">
<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript" src="http://multidatespickr.sourceforge.net/jquery-ui.multidatespicker.js"></script>
<link rel="stylesheet" type="text/css" href="pruebas/css/jquery-ui.theme.css">
<script>
$( document ).ready(function() {
console.log( "ready!" );
var selected = $('#dias option:selected');
var value=selected.val();
$('#id3').multiDatesPicker({
dateFormat: "dd-mm-yy",
maxPicks: value
});
});
</script>
</div>
Thank you.