Posted By

Jamie on 01/26/10


Tagged

javascript html input checkbox firebug


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

wirenaught


HTML generation using JavaScript


 / Published in: JavaScript
 

Run in the FireBug console, and copy the output. An odd class is included for row striping, and the number of items can be controlled via the for loop.

  1. var namesArray;
  2. var names = "Sophie Twigg\nJanine Rappa\nCharley Vidmar\nWillena Tesoro\nSherril Zinke\nAmerica Konkel\nThalia Blackburn\nCatarina Monts\nNanci Haubert\nLoise Blackstock\nLong Kluender\nDelsie Kendricks\nMaurine Mccollister\nMika Lofton\nCathie Woolwine\nLarissa Baumgartner\nChelsey Mellott\nJere Lai\nAntonia Koth\nOlympia Selzer\nLatrisha Points\nSherrill Lis\nDemetrius Bien\nRobbie Leto\nGricelda Farlow\nTia Mcmillin\nPam Isakson\nDaisy Paden\nChaya Dejohn\nAmberly Mizer\nJanna Walcott\nDaphne Griffing\nRoselee Brunton\nShaunta Sylva\nLashaun Weisman\nWaneta Zaugg\nMarry Lafata\nReta Sobus\nNorine Curran\nNolan Manzione\nRutha Quesnell\nPercy Michell\nMaryalice Riemann\nLeif Welte\nMasako Charbonneau\nCleveland Dewolf\nErna Boddie\nGlenn Marler\nTerrilyn Coryell\nChrissy Wren\nCordia Lizardo\nMelissia Golan\nNatosha Marc\nDreama Helbig\nNenita Neubert\nWilbur Hetrick\nNadia Mell\nLoida Goens\nDalene Irle\nKatrina Rockefeller\nMarti Asselin\nKeira Whalley\nRonny Haning\nParker Piacente\nWendie Santigo\nJeremy Kantrowitz\nTeena Hemmings\nLuciano Argentieri\nNita Streater\nFidela Oberman\nDaniella Strawder\nPhyliss Inclan\nCalvin Flory\nInez Hinderman\nRosalind Berns\nTyson Brooker\nMaryjo Ro\nLorilee Jiang\nChing Sturtevant\nLyda Panetta";
  3.  
  4. namesArray = names.split("\n");
  5.  
  6. for(i=200; i < 270 ; i++){
  7. j = i-199
  8. if(i%2){
  9. oddClass = ' class="odd"';
  10. }else{
  11. oddClass = '';
  12. }
  13. console.log('<li'+oddClass+'><input id="id_'+i+'" type="checkbox" name="'+i+'" /><label for="id_'+i+'">'+namesArray[j]+'</label></li>');
  14. }

Report this snippet  

You need to login to post a comment.