Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > JavaScript > Bibliothèques & Frameworks > jQuery
jQuery Forum d'entraide sur le framework jQuery. Avant de poster : Tutoriels jQuery, FAQ jQuery, Tous les tutoriels JavaScript, Toutes les FAQ JavaScript
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 26/07/2011, 00h52   #1
Futur Membre du Club
 
Inscription : octobre 2006
Messages : 107
Détails du profil
Informations forums :
Inscription : octobre 2006
Messages : 107
Points : 17
Points : 17
Par défaut UI Datepicker, proposer une date par défaut

Bonsoir,

J'ai encore une fois besoin d'aide pour un pb sur lequel je sèche :

J'ai sur une div un datepicker qui renseigne un input hidden de la date choisi que je récupère dans un formulaire qui se ré-affiche.

Comment faire pour que la date sélectionnée reste la même une fois le formulaire envoyé ?

J'ai essayé plusieurs chose (sans succès => d'où ce post !!!):
setdate, getdate, de récupère la valeur du input hidden pour réinjecter...
mais pas moyen...


Code :
1
2
<div id="Date_classeur" style="padding:10px"></div>
<?php echo form_input('date_ex',set_value('date_ex',@$date_ex) 'id="Date_ex" class="hidden"'); ?>
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Date du Classeur
    $(function() {                
        $('#Date_classeur')
            .datepicker({
                    changeYear: true,
                    changeMonth: true,
                    yearRange: '-50:c',
                    dateFormat: 'dd-mm-yy',
                    // beforeShow: alert($('#Date_ex').val()), --> récupére bien la date poster mais ne l'affiche pas dans le datepicker !!! grrrrrrr !!!!
                    // setDate: '12-07-2011', ==> pas vu du tout !!! grrrrr !!!
                    onSelect: function(dateText, inst) {
                            $('#Date_ex').val(dateText);
                            InitPage();
                    }
            });
    });
Ps : je développe sous codeigniter... s'il était nécessaire (utile ?) de le dire...
krislec est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/07/2011, 09h30   #2
Rédacteur
 
Avatar de danielhagnoul
 
Homme Daniel Hagnoul
Étudiant perpétuel
Inscription : février 2009
Messages : 3 221
Détails du profil
Informations personnelles :
Nom : Homme Daniel Hagnoul
Âge : 61
Localisation : Belgique

Informations professionnelles :
Activité : Étudiant perpétuel
Secteur : Enseignement

Informations forums :
Inscription : février 2009
Messages : 3 221
Points : 6 767
Points : 6 767
Bonjour

Cette ligne produit quoi dans le navigateur (HTML, CSS, JS, jQuery), pour moi c'est du chinois : <?php echo form_input('date_ex',set_value('date_ex',@$date_ex) 'id="Date_ex" class="hidden"'); ?>.
__________________

FAQ jQuery

Mon cahier d’exercices sur jQuery & Co

Si un message vous a aidé ou vous semble pertinent, votez pour lui !
danielhagnoul est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/07/2011, 09h34   #3
Futur Membre du Club
 
Inscription : octobre 2006
Messages : 107
Détails du profil
Informations forums :
Inscription : octobre 2006
Messages : 107
Points : 17
Points : 17
Oups ... désolé:

en pur code html:
Code :
1
2
<div id="Date_classeur" style="padding:10px"></div>
<input type="text" name="date_ex" value="" id="Date_ex" class="hidden" />
krislec est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/07/2011, 09h36   #4
Responsable Développement Web

 
Avatar de Bovino
 
Homme Didier Mouronval
Développeur Web
Inscription : juin 2008
Messages : 13 807
Détails du profil
Informations personnelles :
Nom : Homme Didier Mouronval
Âge : 41
Localisation : France, Gironde (Aquitaine)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : juin 2008
Messages : 13 807
Points : 35 797
Points : 35 797
Citation:
Comment faire pour que la date sélectionnée reste la même une fois le formulaire envoyé ?
Ben... récupérer le paramètre GET ou POST correspondant pour l'afficher dans le value de l'input à la création de la page...
__________________
Pas de question technique par MP !
Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
Vous possédez un blog et aimeriez diffuser vos billets sur le forum, contactez-moi !
Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
Mon livre sur jQuery
Bovino est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/07/2011, 09h41   #5
Futur Membre du Club
 
Inscription : octobre 2006
Messages : 107
Détails du profil
Informations forums :
Inscription : octobre 2006
Messages : 107
Points : 17
Points : 17
Justement, celui-ci est récupéré par la page (voir les commentaires mis dans le script jquery ) :

Citation:
beforeShow: alert($('#Date_ex').val()), --> récupére bien la date poster mais ne l'affiche pas dans le datepicker !!! grrrrrrr !!!!
mais c'est de l'afficher dans le datepicker, tel qu'il apparait avant l'envoi du formulaire...
krislec est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/07/2011, 09h41   #6
Rédacteur
 
Avatar de danielhagnoul
 
Homme Daniel Hagnoul
Étudiant perpétuel
Inscription : février 2009
Messages : 3 221
Détails du profil
Informations personnelles :
Nom : Homme Daniel Hagnoul
Âge : 61
Localisation : Belgique

Informations professionnelles :
Activité : Étudiant perpétuel
Secteur : Enseignement

Informations forums :
Inscription : février 2009
Messages : 3 221
Points : 6 767
Points : 6 767
Citation:
Envoyé par krislec Voir le message
Oups ... désolé:

en pur code html:
Code :
1
2
<div id="Date_classeur" style="padding:10px"></div>
<input type="text" name="date_ex" value="" id="Date_ex" class="hidden" />
class="hidden" !

<input id="Date_ex" hidden="hidden" type="text" name="date_ex" value="" />
__________________

FAQ jQuery

Mon cahier d’exercices sur jQuery & Co

Si un message vous a aidé ou vous semble pertinent, votez pour lui !
danielhagnoul est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/07/2011, 09h45   #7
Futur Membre du Club
 
Inscription : octobre 2006
Messages : 107
Détails du profil
Informations forums :
Inscription : octobre 2006
Messages : 107
Points : 17
Points : 17
Je sais... je sais çà fait pas beau mais j'ai une classe définit comme telle dans mon css.

.hidden { display : none;}

!!!

Mais je ne pense pas que cela vienne de là... non ?

Citation:
<input id="Date_ex" hidden="hidden" type="text" name="date_ex" value="" />
input reste visible...

mais le pb ne viens pas de là..

je veux juste réafficher dans le calendrier la date précédement envoyé au formuliare:

avant envoi:


apres envoi:


alors que je voudrais:
krislec est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/07/2011, 10h41   #8
Rédacteur
 
Avatar de danielhagnoul
 
Homme Daniel Hagnoul
Étudiant perpétuel
Inscription : février 2009
Messages : 3 221
Détails du profil
Informations personnelles :
Nom : Homme Daniel Hagnoul
Âge : 61
Localisation : Belgique

Informations professionnelles :
Activité : Étudiant perpétuel
Secteur : Enseignement

Informations forums :
Inscription : février 2009
Messages : 3 221
Points : 6 767
Points : 6 767
Il est inutile de s'énerver en postant à tout va, j'avais compris le problème !

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!doctype html><html lang="fr">
<head>
	<meta charset="utf-8">
	<meta name="Author" content="Daniel Hagnoul">
	<title>Forum jQuery</title>
	<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/humanity/jquery-ui.css">
	<link rel="stylesheet" href="http://danielhagnoul.developpez.com/lib/jPicker/css/jPicker.dvjh-1.1.6.min.css" />
	<style>
		/* Base */
		div,p,h1,h2,h3,h4,h5,h6,ul,ol,dl,form,table,img {margin:0px; padding:0px; }
		body {background-color:rgba(210, 214, 98, 0.5); color:#000000; font-family:sans-serif; font-size:medium; font-style:normal; font-weight:normal; line-height:normal; letter-spacing:normal; }
		h1,h2,h3,h4,h5 {font-family:serif; padding:6px; }
		p, div, td {word-wrap:break-word; }
		pre, code {white-space:pre-wrap; word-wrap:break-word; }
		img, input, textarea, select {max-width:100%; }
        img {border:none; }
		h1 {font-size:2em; text-shadow: 4px 4px 4px #bbbbbb; text-align:center; }
		p {padding:6px; }
        ul,ol,dl {list-style:none; padding-left:6px; padding-top:6px; }
        li {padding-bottom:6px; }
		.conteneur {width:95%; min-width:800px; min-height:400px; margin:12px auto; background-color:#FFFFFF; color:#000000; border:1px solid #666666; }
 
		/* article */
		/*
		.conteneur {border-spacing:4px; }
		.ligne {display:table-row; }
		article {display:table-cell; text-align:center; vertical-align:middle; border:1px dotted grey; }
		article:nth-of-type(1) {width:400px; height:120px; }
		*/
 
		/* -- */
 
	</style>
</head>
<body>
	<h1>Forum jQuery</h1>
	<section class="conteneur">
 
		<div id="Date_classeur" style="padding:10px"></div>
 
		<input id="Date_ex" name="date_ex" type="text" value="" />
 
	</section>
	<footer itemscope itemtype="http://data-vocabulary.org/Person">
		<time datetime="2011-07-26T10:45:00.000+02:00" pubdate>2011-07-26</time> <span itemprop="name">Daniel Hagnoul</span> <a href="http://www.developpez.net/forums/u285162/danielhagnoul/" itemprop="url">@danielhagnoul</a>
	</footer>
	<script charset="utf-8" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
	<script charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/i18n/jquery-ui-i18n.min.js"></script>
	<script charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>
	<script charset="utf-8" src="http://danielhagnoul.developpez.com/lib/jPicker/jpicker-1.1.6.min.js"></script>
	<script>
		$(function(){
			/* -- */
 
			$.datepicker.setDefaults( $.datepicker.regional[ "fr" ] );
 
			// mettre une date par défaut, mais au dateFormat :aie:
			// et dans la zone yearRange
			$('#Date_ex').val("08-08-1977");
 
			$('#Date_classeur').datepicker({
				changeYear: true,
				changeMonth: true,
				yearRange: '-50:c',
				dateFormat: 'dd-mm-yy',
				defaultDate: $('#Date_ex').val(),
				onSelect: function(dateText, inst) {
					$('#Date_ex').val(dateText);
 
					//InitPage();
				}
			});
 
			/* jPicker : http://www.digitalmagicpro.com/jPicker/, outil pour choisir rapidement une couleur */
			$.fn.jPicker.defaults.images.clientPath="http://danielhagnoul.developpez.com/lib/jPicker/images/";
			$(".conteneur").jPicker({window:{expandable:true,title:"jPicker : choissisez une couleur :",
			alphaSupport:true,position:{x:'screenCenter',y:'top'}},color:{ active:new $.jPicker.Color({ r: 210, g: 214, b: 98, a: 128 })}},
			function(color, context){var c = color.val("all");if (c){$("body").css("backgroundColor", "rgba(" +
			c.r + "," + c.g + "," + c.b + "," + (c.a/255).toFixed(2) + ")");}});
		});
	</script>
</body>  
</html>
__________________

FAQ jQuery

Mon cahier d’exercices sur jQuery & Co

Si un message vous a aidé ou vous semble pertinent, votez pour lui !
danielhagnoul est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/07/2011, 11h00   #9
Futur Membre du Club
 
Inscription : octobre 2006
Messages : 107
Détails du profil
Informations forums :
Inscription : octobre 2006
Messages : 107
Points : 17
Points : 17
Super....
Effectivement la seule chose que je n'ai testé "defaultDate" car je croyais que ce qui permettait de définir la date du jour actuel.

Un Super GRAND MERCI, et désolé pour les posts, mais c'était juste pour être plus clair...

Perso, c'est 6 étoiles que je te mets Daniel !

Merci à tous.
krislec est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 07h33.


 
 
 
 
Partenaires

Hébergement Web