JSFiddle - React, Tailwind, and code Playground

HTML

<p>Dia
    <select name="dia" id="dia"></select>Mes
    <select name="mes1" id="mes" onchange="fillDia(this)"></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>
    
    
<script>
// generate dia items
var dia = new Array();
    
fillDia(document.getElementById('mes')); 
    
function fillDia(opt) {
    // empty dia select element options
    document.getElementById('dia').options.length = 0;
    
    var maxDays = 31;
    //alert (opt.value);
    if (opt.value == '2') maxDays = 28; //feburary
    if (opt.value == '4' || opt.value == '6' || opt.value == '9' || opt.value == '11') maxDays = 30; //april , june , september , november
    
    for (i = 1; i <= maxDays; i++) {
        dia[i] = i;
    }
    //se guarda el select dia
    var dias = document.getElementById('dia');

    //generar select para dia
    for (var i = 1; i <= maxDays; i++) {
    var option = document.createElement('option');
    option.innerHTML = dia[i];
    option.value = dia[i];
        dias.appendChild(option);
    }
    
}        
    </script>

JavaScript

//generar meses
var mes = new Array();
for (i = 1; i <= 12; i++) {
    mes[i] = i;
}

//se guarda el select mes
var seleccionar = document.getElementById('mes');

//generar select para meses
for (var i = 1; i < mes.length; i++) {
    var option = document.createElement('option');
    option.innerHTML = mes[i];
    option.value = mes[i];
    seleccionar.appendChild(option);
}



//generar años
var año = new Array();
for (i = 1950; i <= 2014; i++) {
    año[i] = i;
}

//se guarda el select año
var seleccionar = document.getElementById('año');

//generar select para años
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);
}