I am back. How am I suppose to change a select content if I choose an option of other select. This is my JSFiddle. What I want is that if I select the 'mes' = 2 option (february). It shows me only 28 days on the 'dia' select (days). I don't know how to refer when the number 2 is selected so I can build a if structure. Thx in advance, my english is not the best... (I don't wanna use JQuery)
This is my whole HTML:
<p>Dia
<select name="dia" id="dia"></select>Mes
<select name="mes1" id="mes"></select>Año
<select name="año" id="año"></select>
</p>
<p>
<input type="text" name="txtFecha1" id="txtFecha1" disabled/>
<input type="submit" name="capturar" id="capturar" value="Capturar" onclick="capturar()" />
</p>
<p>
<input type="text" name="txtFecha2" id="txtFecha2" disabled/>
<input type="submit" name="capturar2" id="capturar2" value="Capturar" onclick="capturar()" />
</p>
<p>
<input type="submit" name="diferencia" id="diferencia" value="Diferencia" onclick="diferencia()" />
</p>
<p id="pParrafo">Dias entre las fechas:</p>
onClick functions are not programmed yet.
This is the JS:
var mes = new Array();
for (i = 1; i <= 12; i++) {
mes[i] = i;
}
var seleccionar = document.getElementById('mes');
for (var i = 1; i < mes.length; i++) {
var option = document.createElement('option');
option.innerHTML = mes[i];
option.value = mes[i];
seleccionar.appendChild(option);
}
var año = new Array();
for (i = 1950; i <= 2014; i++) {
año[i] = i;
}
var seleccionar = document.getElementById('año');
for (var i = 1950; i < año.length; i++) {
var option = document.createElement('option');
option.innerHTML = año[i];
option.value = año[i];
seleccionar.appendChild(option);
}