0
I have the following datepicker:
var dataIni = document.querySelector("#calendarioIni");
var dataFim = document.querySelector("#calendarioFim");
function checaVazio(){
var botao = document.querySelector("form input[type='submit']");
botao.style.display = dataIni.value && dataFim.value ? "inline" : "none";
}
var start = new Date(1998, 00, 01);
var end = new Date(1998, 11, 31) ;
$(document).ready(function()
{
$('#calendarioIni').datepicker({
format: 'dd/mm/yyyy',
startDate: '01/01/1998', // 1 de Janeiro de 1998
endDate: '31/12/1998', // 31 de Janeiro de 1998,
defaultViewDate: { year: 1998, month: 0, day: 1 },
onSelect: checaVazio
});
});
$(document).ready(function()
{
$('#calendarioFim').datepicker({
defaultViewDate: new Date(1998, 0, 1),
endDate: end,
startDate: start,
onSelect: checaVazio
});
});
I would like to change the month that appears when I open the calendar (currently when I click opens in December, I wanted to change to January), I tried to do this with "startView" but it didn’t work. So I use it:
<form method="post" action="">
Início do período:
<input type="text" id="calendarioIni" name="dataInicio">
Fim do período:
<input type="text" id="calendarioFim" name="dataFim">
<input style="display: none;" type="submit" value="Consultar" />
<br><br><br>
<?php if(isset($_POST['dataInicio']) && isset($_POST['dataFim']))
{
$dataIni = $_POST['dataInicio'];
$dataFim = $_POST['dataFim'];
echo $dataIni."<br>";//Teste para verificar o valor nas variáveis que recebem a data via POST
echo $dataFim."<br>";
}
?>
</form>
Add to your question by explaining which datepicker component you are using. If you can, create executable code in jsfiddle.net.
– Pagotti
What did you mean by component? If it is bootstrap?
– V.Avancini
component even because datepicker is not something native to Javascript. For example, it may be the Datepicker of Jquery UI or it may be another.
– Pagotti
So, using bootstrap and jquery, I basically call it <script type='text/javascript' src='.. /js/plugins/bootstrap/bootstrap-datepicker.js'></script>
– V.Avancini
You wouldn’t have to
$(document).ready(function () { ... });
twice. You can do everything within a single block. And thedefaultViewDate
of#calendarioFim
is incorrect. You have to use the same format as the#calendarioIni
, that is, pass an object with the attributesyear
,month
andday
.– user98628
i tbm use for a Datatable, could put together too?
– V.Avancini
You can. If you share the same event, you can put.
– user98628
I get it, but they don’t share the same event
– V.Avancini
I just can’t understand the following: I went to the datepicker class and made some modifications, for example, I changed the language, but I don’t apply this modification... the behavior is kind of random, there are changes that I make that change and others don’t
– V.Avancini
If all three are within the scope of one
$(document).ready(function () { ... });
, then share the same event that is when the GIFT is fully charged. There you can unite into one.– user98628
but do not share... the first generates a table to generate a pdf and the second is to display the calendar and the user select the dates
– V.Avancini
If you reference your datepicker this way (pointing to a file in the local JS folder) there is no way to know which component it is. There are dozens of datepicker components that use bootstrap so it is interesting you indicate which site you downloaded from because each has different configuration and behavior.
– Pagotti
@Pagotti worse than there is no way I know where it was downloaded, because I "inherited" this project
– V.Avancini