Programmation » créer des checkBox dynamiquement
Catégorie:  
   
créer des checkBox dynamiquement
Publié le 21/05/2012 @ 14:10:08,
Par kayumba
Bonjour,

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 Clandestino
Ce 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 kayumba
auriez vous un example SVP ?
   
créer des checkBox dynamiquement
Publié le 21/05/2012 @ 16:03:46,
Par Clandestino
En me basant sur le code ci-dessus et en partant du principe que chaque DIV avec une classe "label_check" doit contenir une checkbox :

  1. $(document).ready(function() { 
  2.   var _numrayon = 0
  3.   $('.label_check').each(function() { 
  4.     var _rayon = _numrayon.toString(); 
  5.     $(this).append('<input type="checkbox" name="Rayon' + _rayon + '" value="' + _rayon + '" /> RAYON ' + _rayon); 
  6.     _numrayon = _numrayon + 1
  7.   }); 
  8. });
   
créer des checkBox dynamiquement
Publié le 22/05/2012 @ 16:06:24,
Par kayumba
j'en ai utilisé une gridvieuw et à l’intérieur j'ai mis un checkBox ça marche.
Merci
Répondre - Catégorie:  
Informaticien.be - © 2002-2024 AkretioSPRL  - Generated via Kelare
The Akretio Network: Akretio - Freedelity - KelCommerce - Votre publicité sur informaticien.be ?