datepicker help....

Vera

Utente Attivo
3 Giu 2014
76
1
8
Buongiorno a tutti,

Ho prelevato questo script dalla rete:

Codice:
<script type="text/javascript">
$(function()
{
    $.datepicker.regional['it'] = 
    {
        currentText: 'Oggi', currentStatus: 'Mese corrente',
        monthNames: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'],
        monthNamesShort: ['Gen','Feb','Mar','Apr','Mag','Giu','Lug','Ago','Set','Ott','Nov','Dic'],
    };
    $.datepicker.setDefaults($.datepicker.regional['it']);
    
$( "#from, #to" ).datepicker({
           changeMonth: true,
           changeYear: true,
           showButtonPanel: true,
           dateFormat: 'MM yy',           
           onClose: function(dateText, inst) {
               var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
               var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();            
               $(this).datepicker('setDate', new Date(year, month, 1));
           },
           beforeShow : function(input, inst) {
               if ((datestr = $(this).val()).length > 0) {
                   year = datestr.substring(datestr.length-4, datestr.length);
                   month = jQuery.inArray(datestr.substring(0, datestr.length-5), $(this).datepicker('option', 'monthNames'));
                   $(this).datepicker('option', 'defaultDate', new Date(year, month, 1));
                   $(this).datepicker('setDate', new Date(year, month, 1));   
               }
               var other = this.id == "from" ? "#to" : "#from";
               var option = this.id == "from" ? "maxDate" : "minDate";       
               if ((selectedDate = $(other).val()).length > 0) {
                   year = selectedDate.substring(selectedDate.length-4, selectedDate.length);
                   month = jQuery.inArray(selectedDate.substring(0, selectedDate.length-5), $(this).datepicker('option', 'monthNames'));
                   $(this).datepicker( "option", option, new Date(year, month, 1));
               }
           }
       });
       $("#buttonShow").click(function()
       {
           if ($("#from").val().length == 0 || $("#to").val().length == 0)
           {
               $('#dialog ').dialog(
               {
                   modal: true,
                   buttons: 
                   {
                       "Esci": function() 
                       {
                           $( this ).dialog( "close" );
                       }
                   }
               }); 
               return;
           }
           else
           {
               var dtiniz = $('input[name=from]').val();  
               var dtfine = $('input[name=to]').val();  
           }
       })
});
</script>

<style>
.ui-datepicker-calendar {
    display: none;
    }
</style>

con il mio codice HTML:

HTML:
<table border="0" width="100%">
<tr> 
<td>
<label for="from"><b>Dal</b></label>
<input type="text" name="from" id="from" style="width:100px" tabindex="-1" />

<label for="to"><b>al</b></label>
<input type="text" name="to" id="to" style="width:100px" tabindex="-1" />
 
<input type="button" onclick="Procedi()" value="Procedi" style="width:120px"/>
</td>
</tr>
</table>

che richiama il mio script Procedi:

Codice:
function Procedi(cduser)
{
   var dtiniz = $('input[name=from]').val();
   var dtfine = $('input[name=to]').val(); alert(dtiniz); alert(dtfine);
   ........
   ........


la mia necessita é quella di avere nei due alert dello script i seguenti valori

ad esempio 06/2014 e 07/2014
o ancora meglio se definisco quattro variabili:

var dtanno1 = ....
var dtanno2 = ....
var dtmese1 = ....
var dtmese2 = ....

avere i seguenti valori: 2014 2014 06 07

come posso fare?
Grazie
 

criric

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
21 Ago 2010
5.607
54
48
TN
Cioa, puoi provare in questo modo
Codice:
function Procedi()
    {
        var dtiniz = $('input[name=from]').val();        
        var split = dtiniz.split(" ");
        var mesedtiniz = split[0];
        alert(mesedtiniz);
        var annodtiniz = split[1];
        alert(annodtiniz);        
        
    }
 

Vera

Utente Attivo
3 Giu 2014
76
1
8
Ciao grazie per la tua risposta.

Scusami se ti rispondo in ritardo ma sono stata impegnata per altro.
vera
 
Discussioni simili
Autore Titolo Forum Risposte Data
D inserire datepicker in un form - help HTML e CSS 4
max1974 DatePicker e DateTimePicker Javascript 0
A [PHP] Datepicker Not Displaying Correctly PHP 1
A [Javascript] Datepicker - il calendario non si apre Javascript 16
V Somma anni ad una data con datepicker jQuery 1
K [Javascript] datepicker Javascript 12
E Formato data datepicker HTML5 HTML e CSS 5
A problemi con datepicker Javascript 6
F Problema attivare/disattivare immagine calendario datepicker da select jQuery 1
B Mostra/nascondi option su confronto datepicker PHP 0
J Problema con datepicker js Javascript 4
G datePicker in plugin PAFacile PHP 1
R datepicker e ajax Javascript 0
M Help for Linux Bash Programmazione 1
E Help Sql somma orari PHP 32
P Passare i risultati di un foreach in un modal. Help! PHP 2
J help me C/C++ 1
K Help: problema con uno script di booking in php! PHP 0
Q HELP ME PLEASE!‼️‼️ E-Commerce 1
L difficoltà con Xampp. printing php mancante...help Web Server 6
K [PHP] Help me a problem... Pleases PHP 1
S Problemi con modulo upload video php (help!) PHP 0
M HELP FORM CREATO IN PHP PHP 14
M Help - consultare (ed esportare) dati da un DB pubblico mySql PHP 2
S [PHP] help me!! PHP 2
F Cerco contatto tipo help-desk Offerte e Richieste di Lavoro e/o Collaborazione 2
F Help-PDO copiare Database MySQL PHP 3
Andrea1981 [WordPress] [HTML] Help modifica credits nel footer.Tema Customizr. WordPress 5
simgia [Javascript] Google maps help! Javascript 1
S [WordPress] Footer php - il background riempie tutta la pagina - help WordPress 1
A funzioni asincrone e callback...help! Ajax 10
F Help array da javascript a php Javascript 2
M [PHP] Help: controllo valori inseriti in un campo PHP 1
P Help con js/php PHP 6
N Sistema di Help di Delphi 7 non funziona su Win10 Windows e Software 0
silvia88 ***Help*** - Anteprima immagine photoshop diversa da file Photoshop 3
A HELP: vedo il sito posizionato in serp solo con i tool di posizionamento!!! SEO e Posizionamento 3
T [PHP] Calcolo anzianità soggetti [era: Help me :( Esercizio per me impossibile] PHP 9
trattorino Creare codice php help PHP 26
CoyotesSon [PHP] Help! Creazione di una finestra PHP 5
V help java Java 2
L help me Presentati al Forum 0
L N00b need help Webdesign e Grafica 2
I Help - Problema installazione tema di themeforest WordPress 1
claudiav ciao!! help.. Presentati al Forum 0
Z Invio mail da telecamere HIKVision - HELP!!! IP Cam e Videosorveglianza 0
M - WordPress - Sito Annunci HELP ME!!!! :crying: WordPress 2
L Hosting, help HTML e CSS 2
M HoneyPot su macchina virtuale HELP ME PLEASE!!! Reti LAN e Wireless 0
F Help con leaseweb Hosting 2

Discussioni simili