I have a datepicker on my website with which I intend to pass the selected date through the url, for example, to update certain information on that website. (I do not want to use Ajax).
The problem is that as I have done it, the form always captures the value of the date 1 click later. That is, the first value is captured in white and the next click, the first value I put and so on. I attach the code:
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker();
$("#format").change(function() { $('#datepicker').datepicker('option', {dateFormat: $(this).val()}); });
});
</script>
</head>
<body>
<?php
echo 'Fecha recibida: '.$_POST['fecha'].'<br>';
$partes = explode('/', $_POST['fecha']);
$fecha = $partes[2].'-'.$partes[0].'-'.$partes[1];
echo 'Fecha formateda para meter en base de datos: '.$fecha.'<br><br>';
?>
<form action="perfil.php?perfil=<?php echo $perfil; ?>&inicio=<?php echo $fecha; ?>" method="POST"/>
<div class="demo">
Selecciona fecha: <input id="datepicker" type="text" name="fecha">
<input type="submit" name="nuevafecha" value="Enviar"/>
</div>
</form>
Can someone help me? Thanks.