Hi,

I am trying to introduce a multiple datepicker into a webpage and the
problem arises with the second picker. I tried to copy and adapt the code I
employed for the first one, renaming the variables but it is simply unable
to output any date to the database. The code for the first picker (which
works fine) is as follows:



<html>
<head>
<script type="text/javascript">

var numDays = {
'1': 31, '2': 28, '3': 31, '4': 30, '5': 31, '6': 30,
'7': 31, '8': 31, '9': 30, '10': 31, '11': 30, '12': 31
};

function setDays(oMonthSel, oDaysSel, oYearSel)
{
var nDays, oDaysSelLgth, opt, i = 1;
nDays = numDays[oMonthSel[oMonthSel.selectedIndex].value];
if (nDays == 28 && oYearSel[oYearSel.selectedIndex].value % 4 == 0)
++nDays;
oDaysSelLgth = oDaysSel.length;
if (nDays != oDaysSelLgth)
{
if (nDays < oDaysSelLgth)
oDaysSel.length = nDays;
else for (i; i < nDays - oDaysSelLgth + 1; i++)
{
opt = new Option(oDaysSelLgth + i, oDaysSelLgth + i);
oDaysSel.options[oDaysSel.length] = opt;
}
}
var oForm = oMonthSel.form;
var month = oMonthSel.options[oMonthSel.selectedIndex].value;
var day = oDaysSel.options[oDaysSel.selectedIndex].value;
var year = oYearSel.options[oYearSel.selectedIndex].value;
oForm.f_despara.value = month + '/' + day + '/' + year;
}
</head>
<body>
<form>
<table>
<tr>
<td>
<select name="day" class="buscar" id="day"
onChange="setDays(month,this,year)">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option selected>D&iacute;a</option>
</select></td>
<td><select name="month" class="buscar" id="month"
onchange="setDays(this,day,year)">
<option value="1">Enero</option>
<option value="2">Febrero</option>
<option value="3">Marzo</option>
<option value="4">Abril</option>
<option value="5">Mayo</option>
<option value="6">Junio</option>
<option value="7">Julio</option>
<option value="8">Agosto</option>
<option value="9">Septiembre</option>
<option value="10">Octubre</option>
<option value="11">Noviembre</option>
<option value="12">Diciembre</option>
<option selected>Mes</option>
</select></td>
<td><select name="year" class="buscar" id="year"
onchange="setDays(month,day,this)">
<option value="1995">1995</option>
<option value="1996">1996</option>
<option value="1997">1997</option>
<option value="1998">1998</option>
<option value="1999">1999</option>
<option value="2000">2000</option>
<option value="2001">2001</option>
<option value="2002">2002</option>
<option value="2003">2003</option>
<option value="2004">2004</option>
<option selected>A&ntilde;o</option>
</select>
<input type="hidden" name="f_despara" value="" />
</td>
</tr>
</table>
</form>
</body>
</html>




Then I tried to add a second date picker and never worked. I tried this way:
I added another function to the script:



function setDays2(oMonth2Sel, oDays2Sel, oYear2Sel)
{
var nDays2, oDays2SelLgth, opt2, i2 = 1;
nDays2 = numDays[oMonth2Sel[oMonth2Sel.selectedIndex].value];
if (nDays2 == 28 && oYear2Sel[oYear2Sel.selectedIndex].value % 4 == 0)
++nDays2;
oDays2SelLgth = oDays2Sel.length;
if (nDays2 != oDays2SelLgth)
{
if (nDays2 < oDays2SelLgth)
oDays2Sel.length = nDays2;
else for (i2; i2 < nDays2 - oDays2SelLgth + 1; i2++)
{
opt = new Option(oDays2SelLgth + i2, oDays2SelLgth + i2);
oDays2Sel.options[oDays2Sel.length] = opt2;
}
}
var oForm2 = oMonth2Sel.form;
var month2 = oMonth2Sel.options[oMonth2Sel.selectedIndex].value;
var day2 = oDays2Sel.options[oDays2Sel.selectedIndex].value;
var year2 = oYear2Sel.options[oYear2Sel.selectedIndex].value;
oForm.f_vac1.value = month2 + '/' + day2 + '/' + year2;
}



and then added the date picker fields to the form:



<tr>
<td><select name="day2" class="buscar" id="day2"
onChange="setDays2(month2,this,year2)">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option selected>D&iacute;a</option>
</select></td>
<td><select name="month2" class="buscar" id="month2"
onchange="setDays2(this,day2,year2)">
<option value="1">Enero</option>
<option value="2">Febrero</option>
<option value="3">Marzo</option>
<option value="4">Abril</option>
<option value="5">Mayo</option>
<option value="6">Junio</option>
<option value="7">Julio</option>
<option value="8">Agosto</option>
<option value="9">Septiembre</option>
<option value="10">Octubre</option>
<option value="11">Noviembre</option>
<option value="12">Diciembre</option>
<option selected>Mes</option>
</select></td>
<td><select name="year2" class="buscar" id="year2"
onchange="setDays2(month2,day2,this)">
<option value="1995">1995</option>
<option value="1996">1996</option>
<option value="1997">1997</option>
<option value="1998">1998</option>
<option value="1999">1999</option>
<option value="2000">2000</option>
<option value="2001">2001</option>
<option value="2002">2002</option>
<option value="2003">2003</option>
<option value="2004">2004</option>
<option selected>A&ntilde;o</option>
</select>
<input type="hidden" name="f_vac1" value="" />
</td>
</tr>



The script works well avoiding invalid date on the form but never passes the
value to the database.

Could someone help me?

Thanks in advance,

Gustavo