Estoy intentando generar un calendario para seleccionar una fecha y una hora con javascript. He encontrado muchos ejemplos del siguiente estilo que funcionan:
Código:
Pero lo que yo quiero hacer es lo siguiente (dentro de un script y habiendo incluido los .js i .css necesarios):<form> <input type="text" id="date" name="date" /> <input type="button" id="butt" value="..." /> </form> <script type="text/javascript"> Calendar.setup( { inputField : "date", ifFormat : "%d/%m/%Y", button : "butt" } ); </script>
Código:
(divdest es un div que he creado anteriormente)txt = document.createTextNode('Start Time: '); divdest.appendChild(txt); st = document.createElement('input'); st.name = 'txtdate'; st.value = ''; divdest.appendChild(st); butt = document.createElement('button'); butt.value = '...'; butt.id = 'butt'; divdest.appendChild(butt); var cal = new Calendar.setup({ inputField : 'txtdate';, // id of the input field singleClick : false, // require two clicks to submit ifFormat : '%a, %b %e, %Y [%I:%M %p]', // format of the input field showsTime : true, // show time as well as date button : 'butt'; // trigger button });
Pero esto no funciona, si alguien me pudiera decir como hacer para crear un calendario generado completamente con javascript (sin la necesidad de definir los inputs con html).
Muchas gracias!!!!