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

JavaScript Discussion :

[mise � jour tableau en fonction du button radio]


Sujet :

JavaScript

Vue hybride

Message pr�c�dent Message pr�c�dent   Message suivant Message suivant
  1. #1
    Membre confirm�
    Profil pro
    Inscrit en
    Ao�t 2005
    Messages
    142
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Ao�t 2005
    Messages : 142
    Par d�faut [mise � jour tableau en fonction du button radio]
    je souhaite faire l'apparition d'un tableau ou de l'autre en fonction du bouton radio choisi, voil� ce que j'ai fait:

    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    <script language="javascript">
    function AffichTab(element)
    {
    if (f.radiobutton.value == "Tavail")
    	{
    		document.getElementById('element').visible='true';
    	}
    }
    </script>

    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
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
     
    <form name="f">
      <table width="200" border="1">
      <tr class="corpsTexte">
        <td width="70"><input type="radio" name="radiobutton" value="Tavail" onClick="AffichTab(TabHoraire)">
    Trav.</td>
        <td width="70"><input type="radio" name="radiobutton" value="Absence" onClick="AffichTab(TabAbsence)">
    Abs.</td>
      </tr>
    </table>
     
      <table width="200" border="0">
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
     
      <table id="TabHoraire" width="200" border="1" style=" visibility:hidden">
        <tr class="TitreCorps">
          <td>Abv</td>
          <td width="154">Profil Horaire </td>
        </tr>
        <tr>
          <td width="30"><div align="center">
            <input type="text" border="0" name="Profil" value="" style="cursor:pointer" size="3">
          </div></td>
          <td width="154"><div align="center"></div></td>
        </tr>
      </table>
      <table id="TabAbsence" width="200" border="1" style=" visibility:hidden">
        <tr class="TitreCorps">
          <td>Abv</td>
          <td>Type d'Abscence </td>
        </tr>
        <tr>
          <td width="30"><div align="center">
              <input type="text" border="0" name="Absence" value="" style="cursor:pointer" size="3">
          </div></td>
          <td width="154"><div align="center"></div></td>
        </tr>
      </table>
    </form>
    N'�tant pas tr�s experte en javascript, toute l'aide que vous m'apporterez sera la bien venue.

  2. #2
    Expert confirm� Avatar de Mr N.
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    5 418
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 5 418
    Par d�faut
    Cadeau, j'ai cherch� pour toi
    http://www.developpez.net/forums/viewtopic.php?t=409314
    (Regarde � la fin, il y a une proposition qui tient la route, � adapter suivant tes besoins bien sur !)

  3. #3
    Membre confirm�
    Profil pro
    Inscrit en
    Ao�t 2005
    Messages
    142
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Ao�t 2005
    Messages : 142
    Par d�faut
    c'est sur que c'est parfait!!

    Merci

  4. #4
    Membre confirm�
    Profil pro
    Inscrit en
    Ao�t 2005
    Messages
    142
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Ao�t 2005
    Messages : 142
    Par d�faut
    �a marche bien sauf que lorsque je mets un input type=text dans mon div j'ai une erreur que je n'ai plus lorque j'enl�ve cet input.

    Mais j'ai absolument besoin de l'input type=text!!


    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
    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
     
    <html> 
       <script language="javascript"> 
          var iscomplete = false; 
     
          function checkform5() 
          { 
             iscomplete = false; 
             varnb = 0; 
             for (i=0;i<=document.form1.elements.length-1;i++) 
             { 
                if (document.form1.nbimg[i].checked == true) 
                { 
                   iscomplete = true; 
                   varnb = i + 1; 
                } 
             } 
     
             switch (varnb) 
             { 
                case 1: 
                   cache1.style.visibility="VISIBLE"; 
                   cache2.style.visibility="HIDDEN"; 
                   cache3.style.visibility="HIDDEN"; 
                   break; 
                case 2: 
                   cache1.style.visibility="HIDDEN"; 
                   cache2.style.visibility="VISIBLE"; 
                   cache3.style.visibility="HIDDEN"; 
                   break; 
                case 3: 
                   cache1.style.visibility="HIDDEN"; 
                   cache2.style.visibility="HIDDEN"; 
                   cache3.style.visibility="VISIBLE"; 
                   break; 
             } 
          } 
       </script> 
     
       <body> 
    <form name="form1">
    <table width="200" border="1">
      <tr class="corpsTexte">
        <td width="70"><input type="radio" name="nbimg" value="1" onClick="checkform5()" >Trav.</td>
        <td width="70"><input type="radio" name="nbimg" value="2" onClick="checkform5()">Abs.</td>
      </tr>
    </table> 
    <table width="200" border="0">
      <tr><td>&nbsp;</td></tr>
    </table>      
    <div id="cache1" style="visibility:hidden;">
      <table width="200" border="1">
        <tr class="TitreCorps">
          <td>Abv</td>
          <td width="154">Profil Horaire </td>
        </tr>
    	<tr>
          <td width="30" height="24"><input type="text" border="0" name="Profil" value="" style="cursor:pointer" size="3"></td>
          <td width="154"><div align="center"></div></td>
        </tr>
     
      </table>
    </div> 
    <div id="cache2" style="visibility:hidden;">Div2</div> 
    <div id="cache3" style="visibility:hidden;">Div3</div> 
    </form> 
    </body> 
    </html>

    please je s�che!!

  5. #5
    Expert confirm� Avatar de Mr N.
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    5 418
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 5 418
    Par d�faut
    Boule de cristal, � boule de cristal ! Peux tu me donner l'erreur qu'a obtenu Lady_jade ?

  6. #6
    Membre confirm�
    Profil pro
    Inscrit en
    Ao�t 2005
    Messages
    142
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Ao�t 2005
    Messages : 142
    Par d�faut
    la boule de cristal de voit rien

    puisque rien ne s'affiche ;o)

    suivant que quand je mets
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
     
    <input type="text" border="0" name="Profil" value="" style="cursor:pointer" size="3">
    j'ai une page blanche

    et qd j'enl�ve �a mache???

    et oui j'ai fais attention � la fermeture de me balises!

  7. #7
    Expert confirm� Avatar de Mr N.
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    5 418
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 5 418
    Par d�faut
    Citation Envoy� par Lady_jade
    lorsque je mets un input type=text dans mon div j'ai une erreur
    D�sol� je me base sur ce que tu me donnes

  8. #8
    Expert confirm� Avatar de Mr N.
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    5 418
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 5 418
    Par d�faut
    On efface tout et on recommence :
    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
    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
    <script type="text/javascript">
    function AffichTab(table)
    {
      	document.getElementById('TabHoraire').style.display = 'none';
      	document.getElementById('TabAbsence').style.display = 'none';
      	document.getElementById(table).style.display        = 'block';
    } 
    </script>
     
    <form name="f">
      <table width="200" border="1">
      <tr class="corpsTexte">
        <td width="70"><input type="radio" name="radiobutton" value="Tavail" onClick="AffichTab('TabHoraire');">
    Trav.</td>
        <td width="70"><input type="radio" name="radiobutton" value="Absence" onClick="AffichTab('TabAbsence');">
    Abs.</td>
      </tr>
    </table>
     
      <table width="200" border="0">
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
     
      <table id="TabHoraire" width="200" border="1" style="display:none">
        <tr class="TitreCorps">
          <td>Abv</td>
          <td width="154">Profil Horaire </td>
        </tr>
        <tr>
          <td width="30"><div align="center">
            <input type="text" border="0" name="Profil" value="" style="cursor:pointer" size="3">
          </div></td>
          <td width="154"><div align="center"></div></td>
        </tr>
      </table>
      <table id="TabAbsence" width="200" border="1" style="display:none">
        <tr class="TitreCorps">
          <td>Abv</td>
          <td>Type d'Abscence </td>
        </tr>
        <tr>
          <td width="30"><div align="center">
              <input type="text" border="0" name="Absence" value="" style="cursor:pointer" size="3">
          </div></td>
          <td width="154"><div align="center"></div></td>
        </tr>
      </table>
    </form>
    C'est cod� bourrin, � toi de rendre ca plus propre !

    HTH

  9. #9
    Membre confirm�
    Profil pro
    Inscrit en
    Ao�t 2005
    Messages
    142
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Ao�t 2005
    Messages : 142
    Par d�faut
    oui oui oups

    j'ai

    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
     
    'document.form1.nbimg[...].checked' a la valeur null ou n'est pas un objet
    et donc ma page est vide

  10. #10
    Membre confirm�
    Profil pro
    Inscrit en
    Ao�t 2005
    Messages
    142
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Ao�t 2005
    Messages : 142
    Par d�faut
    merci du coup de main �a marche

  11. #11
    Membre confirm�
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    98
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 98
    Par d�faut
    Citation Envoy� par Lady_jade
    merci du coup de main �a marche
    Salut,

    �a marche sous Firefox ?

    Parce que j'ai le m�me genre de code que toi et sous IE ok mais sous Firefox, le tableau apparait bien mais la taille des cellules (propri�t� width) n'est plus du tout respect�e quand je fais block.
    Du coup, je fais :

    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    document.getElementById(table).style.display = '';
    Et l� ca marche !
    a+

+ R�pondre � la discussion
Cette discussion est r�solue.

Discussions similaires

  1. Mise � jour tableau excel sous word
    Par christophe.rousset dans le forum Word
    R�ponses: 1
    Dernier message: 13/04/2010, 13h52
  2. mise � jour tableau crois� dynamique
    Par pancratee dans le forum Macros et VBA Excel
    R�ponses: 2
    Dernier message: 03/03/2010, 16h35
  3. mise � jour de la fonction somme
    Par moimemessssssssss dans le forum Macros et VBA Excel
    R�ponses: 12
    Dernier message: 14/04/2008, 20h42
  4. pb de mise � jour de la fonction hpagebreak
    Par bybelos33 dans le forum Macros et VBA Excel
    R�ponses: 2
    Dernier message: 11/07/2007, 11h43
  5. Mise � jour Champ en fonction liste modifiable
    Par lito74 dans le forum Access
    R�ponses: 2
    Dernier message: 30/01/2006, 14h37

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