Programmation » créer des checkBox dynamiquement
créer des checkBox dynamiquement
Publié le 21/05/2012 @ 14:10:08, 
Par kayumbaBonjour, 
j’aimerais bien créer des checkBox dynamiquement. donc j'ai une méthode qui m'afficher par example :
RAYON1
RAYON2 etc j'aimerais bien chaque fois que j'affiche le rayon , j'ajoute un checkBox devant.
voici mon code :
<% if (getRayon.Count !=0) for (Int32 iRayon = 1; iRayon < getRayon.Count; iRayon++)
{
          
			                    
%>
<%
CheckBox Box = new CheckBox();
Control pnl = new Control();
Box.ID = "rayon" + iRayon;
Box.Text = "RAYON1";
pnl.Controls.Add(Box);
             
%>
               
<div class="label_check"><%=(getRayon[iRayon].ToString()) %></div>
                
		
<% } %>
j’aimerais bien créer des checkBox dynamiquement. donc j'ai une méthode qui m'afficher par example :
RAYON1
RAYON2 etc j'aimerais bien chaque fois que j'affiche le rayon , j'ajoute un checkBox devant.
voici mon code :
<% if (getRayon.Count !=0) for (Int32 iRayon = 1; iRayon < getRayon.Count; iRayon++)
{
%>
<%
CheckBox Box = new CheckBox();
Control pnl = new Control();
Box.ID = "rayon" + iRayon;
Box.Text = "RAYON1";
pnl.Controls.Add(Box);
%>
<div class="label_check"><%=(getRayon[iRayon].ToString()) %></div>
<% } %>
créer des checkBox dynamiquement
Publié le 21/05/2012 @ 14:53:48, 
Par ClandestinoCe serait bien plus facile de rajouter les checkbox a posteriori en jQuery...
créer des checkBox dynamiquement
Publié le 21/05/2012 @ 15:13:31, 
Par kayumbaauriez vous un example SVP ?
créer des checkBox dynamiquement
Publié le 21/05/2012 @ 16:03:46, 
Par ClandestinoEn me basant sur le code ci-dessus et en partant du principe que chaque DIV avec une classe "label_check" doit contenir une checkbox :
- $(document).ready(function() {
 - var _numrayon = 0;
 - $('.label_check').each(function() {
 - var _rayon = _numrayon.toString();
 - $(this).append('<input type="checkbox" name="Rayon' + _rayon + '" value="' + _rayon + '" /> RAYON ' + _rayon);
 - _numrayon = _numrayon + 1;
 - });
 - });
 
créer des checkBox dynamiquement
Publié le 22/05/2012 @ 16:06:24, 
Par kayumbaj'en ai utilisé une gridvieuw et à l’intérieur j'ai mis un checkBox ça marche.
Merci
Merci
Se connecter
Inscription
Mot de passe perdu
Liste des catégories
Qui a lu ce topic?
Répondre
Version imprimable
Activer la notification