talendguy talendguy - 3 months ago 9
jQuery Question

Choose Date jquery with form

I just want to be able to choose 3 different dates with jquery using forms and send their values with post.

This is my code:

<form action="#" method="post">
Date <input type="text" id="datepicker" name="date1" />
or <input type="text" id="datepicker" name="date2" />
to <input type="text" id="datepicker" name="date3" />
</form>
<input style="height: 10px; display: table-cell; vertical-align: middle; line-height: 0;" name="maquinas" type="submit" value="visualizar" />
<input name="inicio" type="submit" value="INICIO" />
<input name="articulos" type="submit" value="ARTÍCULOS" />
<input name="averias" type="submit" value="AVERÍAS" />
</form>


The problem is that on my browser I only can choose one date with the datepicker.

Answer

As per the Web Strategy you have to use only 1 ID per page since the ID is the Unique Element.

Use the code like this provided below.

<form action="#" method="post"> Date <input type="text" id="date1" name="date1" /> or <input type="text" id="date2" name="date2" /> to <input type="text" id="date3" name="date3" /></form> <input style="height: 10px; display: table-cell; vertical-align: middle; line-height: 0;" name="maquinas" type="submit" value="visualizar" /> <input name="inicio" type="submit" value="INICIO" /> <input name="articulos" type="submit" value="ARTÍCULOS" /> <input name="averias" type="submit" value="AVERÍAS" /> </form>

<script type="text/javascript"> $(document).ready(function(){ $('#date1').datepicker(); $('#date2').datepicker(); $('#date3').datepicker(); }); </script>
Comments