Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/02/2013, 16:10
Avatar de diegoug
diegoug
 
Fecha de Ingreso: mayo-2011
Ubicación: Colombia
Mensajes: 52
Antigüedad: 13 años
Puntos: 1
Pregunta como mostrar datetime piker solo meses y años?

Soy programador en python y trabajo con el framework Django.

No soy un experto en javascript la verdad y tampoco se mucho del este lenguaje de programación, es raro que yo copipaste en este lenguaje, solo lo hago para efectos gráficos en el navegador, como este.

La idea es hacer el mismo datetime piker de jquery pero que solo muestre mes y año como selección, pero en chrome me sale un error que dice:

Uncaught SyntaxError: Unexpected token ILLEGAL

Justo al final del script?

Código:
    <script type="text/javascript">
        $(function(){
            $('#id_desde').datepicker({
                dateFormat: 'mm/yy',
                changeMonth: true,
                changeYear: true,
                onClose: function() {
                    var iMonth = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
                    var iYear = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
                    $(this).datepicker('setDate', new Date(iYear, iMonth, 1));
                },
                beforeShow: function() {
                if ((selDate = $(this).val()).length > 0){
                    iYear = selDate.substring(selDate.length - 4, selDate.length);
                    iMonth = jQuery.inArray(selDate.substring(0, selDate.length - 5), 
                            $(this).datepicker('option', 'monthNames'));
                    $(this).datepicker('option', 'defaultDate', new Date(iYear, iMonth, 1));
                    $(this).datepicker('setDate', new Date(iYear, iMonth, 1));
                }
                }
            });
        });​
    </script>
__________________
_________________________
Diego Alonso Uribe Gamez
Twitter: @DiegoUG