IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

HTML Discussion :

Avoir un contenu de liste déroulante différent par rapprot à une liste déroulante


Sujet :

HTML

  1. #1
    Membre éprouvé
    Avatar de beegees
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mars 2004
    Messages
    3 610
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Enseignement

    Informations forums :
    Inscription : Mars 2004
    Messages : 3 610
    Points : 1 277
    Points
    1 277
    Par défaut Avoir un contenu de liste déroulante différent par rapprot à une liste déroulante
    Bonjour tout le monde,

    Est-il possible de changer les valeurs d'une liste déroulante par rapport au choix d'une autre liste déroulante ?

    Je m'explique :

    J'aimerais que mes visiteurs choisissent un mois (ex février) :

    La liste déroulante jour aurait les valeurs de 1 à 28 (ou 29) et non de 1 à 30 ou 31 par contre, si c'est janvier qui est choisi, on aurait 31 jours dans la liste déroulante "jours".

    Est-ce possible cela ?

    Merci d'avance.

    beegees

  2. #2
    Modérateur
    Avatar de Bisûnûrs
    Profil pro
    Développeur Web
    Inscrit en
    Janvier 2004
    Messages
    9 868
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Janvier 2004
    Messages : 9 868
    Points : 16 258
    Points
    16 258

  3. #3
    Expert confirmé
    Avatar de pc75
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    3 662
    Détails du profil
    Informations personnelles :
    Âge : 69
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2004
    Messages : 3 662
    Points : 4 047
    Points
    4 047
    Par défaut
    Re,

    Pour la saisie de dates, le plus cool est d'utiliser un date picker non ?

  4. #4
    Membre éprouvé
    Avatar de beegees
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mars 2004
    Messages
    3 610
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Enseignement

    Informations forums :
    Inscription : Mars 2004
    Messages : 3 610
    Points : 1 277
    Points
    1 277
    Par défaut
    Salut PC75,

    Merci pour ta réponse.

    Datepicker en ASP ?

    Merci
    beegees

  5. #5
    Expert confirmé
    Avatar de pc75
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    3 662
    Détails du profil
    Informations personnelles :
    Âge : 69
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2004
    Messages : 3 662
    Points : 4 047
    Points
    4 047
    Par défaut
    Re,

    Tu colles ça dans un fichier que tu nommes "ts_picker.js"

    Et tu utilises ce code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
     
    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <title>
    Saisie d'un nouveau corps
    </title>
    <script language="JavaScript" src="ts_picker.js">
    </script>
     
    </HEAD>
    <BODY>
     
    				<input type="text" name="txtDebut" value="<%=Dat%>" size="10" maxlength="10" readonly>
    				<a href="javascript:show_calendar('document.frmSaisie.txtDebut', document.frmSaisie.txtDebut.value);">
    				<img src="images/cal.gif" width="16" height="20" border="0" alt="Cliquez pour le calendrier"></a>
    </BODY>
    </HTML>

  6. #6
    Membre éprouvé
    Avatar de beegees
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mars 2004
    Messages
    3 610
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Enseignement

    Informations forums :
    Inscription : Mars 2004
    Messages : 3 610
    Points : 1 277
    Points
    1 277
    Par défaut
    Re,

    Tu colles ça dans un fichier que tu nommes "ts_picker.js"
    Je vois pas de code javascript .

    Merci
    beegees

  7. #7
    Expert confirmé
    Avatar de pc75
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    3 662
    Détails du profil
    Informations personnelles :
    Âge : 69
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2004
    Messages : 3 662
    Points : 4 047
    Points
    4 047
    Par défaut
    Re,

    Le copier/coller n'est plus ce qu'il était...
    function show_calendar(str_target, str_datetime) {
    var arr_months = ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
    "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"];
    var week_days = ["Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa"];
    var n_weekstart = 1; // day week starts from (normally 0 or 1)

    // Si la date est invalide : Initialisation avec la date du jour
    var test_date = /^(\d+)\/(\d+)\/(\d+)$/;
    if (!test_date.exec(str_datetime))
    {
    var d = new Date();
    var str_datetime = d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getYear();
    }

    var dt_datetime = (str_datetime == null || str_datetime =="" ? new Date() : str2dt(str_datetime));

    var dt_prev_month = new Date(dt_datetime);
    dt_prev_month.setMonth(dt_datetime.getMonth()-1);
    var dt_next_month = new Date(dt_datetime);
    dt_next_month.setMonth(dt_datetime.getMonth()+1);

    var dt_prev_year = new Date(dt_datetime);
    dt_prev_year.setFullYear(dt_datetime.getFullYear()-1);
    var dt_next_year = new Date(dt_datetime);
    dt_next_year.setFullYear(dt_datetime.getFullYear()+1);

    var dt_firstday = new Date(dt_datetime);
    dt_firstday.setDate(1);
    dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
    var dt_lastday = new Date(dt_next_month);
    dt_lastday.setDate(0);

    // html generation (feel free to tune it for your particular application)
    // print calendar header
    var str_buffer = new String (
    "<html>\n"+
    "<head>\n"+
    " <title>Calendrier</title>\n"+
    "</head>\n"+
    "<body bgcolor=\"White\">\n"+
    "<table class=\"clsOTable\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+
    "<tr><td bgcolor=\"#4682B4\">\n"+
    "<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+

    // Ligne Année précédente / suivante
    "<tr>\n <td bgcolor=\"blue\"><a href=\"javascript:window.opener.show_calendar('"+
    str_target+"', '"+ dt2dtstr(dt_prev_year)+"');\">"+
    "<img src=\"images/prev.gif\" width=\"16\" height=\"16\" border=\"0\""+
    " alt=\"Année précédente\"></a></td>\n"+
    " <td align=\"center\" bgcolor=\"blue\" colspan=\"5\">"+
    "<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"
    +" "+dt_datetime.getFullYear()+"</font></td>\n"+
    " <td bgcolor=\"blue\" align=\"right\"><a href=\"javascript:window.opener.show_calendar('"
    +str_target+"', '"+dt2dtstr(dt_next_year)+"');\">"+
    "<img src=\"images/next.gif\" width=\"16\" height=\"16\" border=\"0\""+

    " alt=\"Année suivante\"></a></td>\n</tr>\n"+

    // Ligne Mois précédent / suivant
    "<tr>\n <td bgcolor=\"#4682B4\"><a href=\"javascript:window.opener.show_calendar('"+
    str_target+"', '"+ dt2dtstr(dt_prev_month)+"');\">"+
    "<img src=\"images/prev.gif\" width=\"16\" height=\"16\" border=\"0\""+
    " alt=\"Mois précédent\"></a></td>\n"+
    " <td align=\"center\" bgcolor=\"#4682B4\" colspan=\"5\">"+
    "<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"
    +arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</font></td>\n"+
    " <td bgcolor=\"#4682B4\" align=\"right\"><a href=\"javascript:window.opener.show_calendar('"
    +str_target+"', '"+dt2dtstr(dt_next_month)+"');\">"+
    "<img src=\"images/next.gif\" width=\"16\" height=\"16\" border=\"0\""+
    " alt=\"Mois suivant\"></a></td>\n</tr>\n"

    );

    var dt_current_day = new Date(dt_firstday);
    // print weekdays titles
    str_buffer += "<tr>\n";
    for (var n=0; n<7; n++)
    str_buffer += " <td bgcolor=\"#87CEFA\">"+
    "<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"+
    week_days[(n_weekstart+n)%7]+"</font></td>\n";
    // print calendar table
    str_buffer += "</tr>\n";
    while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
    dt_current_day.getMonth() == dt_firstday.getMonth()) {
    // print row heder
    str_buffer += "<tr>\n";
    for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
    if (dt_current_day.getDate() == dt_datetime.getDate() &&
    dt_current_day.getMonth() == dt_datetime.getMonth())
    // print current date
    str_buffer += " <td bgcolor=\"#FFB6C1\" align=\"right\">";
    else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
    // weekend days
    str_buffer += " <td bgcolor=\"#DBEAF5\" align=\"right\">";
    else
    // print working days of current month
    str_buffer += " <td bgcolor=\"white\" align=\"right\">";

    if (dt_current_day.getMonth() == dt_datetime.getMonth())
    // print days of current month
    str_buffer += "<a href=\"javascript:window.opener."+str_target+

    // ".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+
    ".value='"+dt2dtstr(dt_current_day)+"'; window.close();\">"+

    "<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
    else
    // print days of other months


    //str_buffer += "<a href=\"javascript:window.opener."+str_target+
    //".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+
    str_buffer += "<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
    str_buffer += dt_current_day.getDate()+"</font></a></td>\n";

    // str_buffer += "<a href=\"javascript:window.opener."+str_target+
    // ".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+
    // "<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
    // str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
    dt_current_day.setDate(dt_current_day.getDate()+1);
    }
    // print row footer
    str_buffer += "</tr>\n";
    }
    // print calendar footer
    str_buffer +=
    // "<form name=\"cal\">\n<tr><td colspan=\"7\" bgcolor=\"#87CEFA\">"+
    // "<font color=\"White\" face=\"tahoma, verdana\" size=\"2\">"+
    // "Heure : <input type=\"text\" name=\"time\" value=\""+dt2tmstr(dt_datetime)+
    // "\" size=\"8\" maxlength=\"8\"></font></td></tr>\n</form>\n" +
    // "</table>\n" +
    "</tr>\n</td>\n</table>\n" +
    "</body>\n" +
    "</html>\n";

    var vWinCal = window.open("", "Calendar",
    "width=200,height=235,status=no,resizable=no,top=200,left=200,toolbar=no,location=no,directories=no,menubar=no");

    vWinCal.opener = self;
    var calc_doc = vWinCal.document;
    calc_doc.write (str_buffer);
    calc_doc.close();
    }
    // datetime parsing and formatting routimes. modify them if you wish other datetime format
    function str2dt (str_datetime) {
    // var re_date = /^(\d+)\-(\d+)\-(\d+)\s+(\d+)\\d+)\\d+)$/;
    var re_date = /^(\d+)\/(\d+)\/(\d+)$/;
    if (!re_date.exec(str_datetime))
    return alert("Invalid Datetime format: "+ str_datetime);
    return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
    }
    function dt2dtstr (dt_datetime) {
    return (new String (
    // dt_datetime.getDate()+"-"+(dt_datetime.getMonth()+1)+"-"+dt_datetime.getFullYear()+" "));
    dt_datetime.getDate()+"/"+(dt_datetime.getMonth()+1)+"/"+dt_datetime.getFullYear()));
    }
    function dt2tmstr (dt_datetime) {
    //return;
    return (new String (
    dt_datetime.getHours()+":"+dt_datetime.getMinutes()+":"+dt_datetime.getSeconds()));
    }

  8. #8
    Membre éprouvé
    Avatar de beegees
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mars 2004
    Messages
    3 610
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Enseignement

    Informations forums :
    Inscription : Mars 2004
    Messages : 3 610
    Points : 1 277
    Points
    1 277
    Par défaut
    Salut PC75,

    J'ai fais exactement ce que tu m'as dit et voici dans un premier temps ce que j'obtiens :

    http://164.15.112.38/RSI/pc75.html

    Qu'en penses-tu ?

    Merci et bonne soirée.

    beegees

  9. #9
    Expert confirmé
    Avatar de pc75
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    3 662
    Détails du profil
    Informations personnelles :
    Âge : 69
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2004
    Messages : 3 662
    Points : 4 047
    Points
    4 047
    Par défaut
    Re,

    Il manque les balises form :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
     
    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <title>
    Saisie d'un nouveau corps
    </title>
    <script language="JavaScript" src="ts_picker.js">
    </script>
     
    </HEAD>
    <BODY>
    <form name="frmSaisie">
    				<input type="text" name="txtDebut" value="" size="10" maxlength="10" readonly>
    				<a href="javascript:show_calendar('document.frmSaisie.txtDebut', document.frmSaisie.txtDebut.value);">
    				<img src="images/cal.gif" width="16" height="20" border="0" alt="Cliquez pour le calendrier"></a>
    </form>
    </BODY>
    </HTML>

Discussions similaires

  1. Réponses: 1
    Dernier message: 11/07/2014, 08h58
  2. Réponses: 0
    Dernier message: 01/09/2012, 16h42
  3. Réponses: 3
    Dernier message: 14/08/2012, 10h24
  4. Réponses: 4
    Dernier message: 01/03/2012, 19h50
  5. Réponses: 2
    Dernier message: 29/02/2012, 15h20

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo