Mikijs Posted July 17, 2008 Report Share Posted July 17, 2008 Sveiki, te atkal es :) Jautājums ir šāds: kādā veidā es varu izvilkt visus elementa <select> - option laukus? Ja man ir <select> <option value='152'>Pirmais</option> <option value='718'>Otrais</option> <option value='543'>Trešais</option> <option value='466'>Ceturtais</option> <option value='921'>Piektais</option> </select> Tātad lai būtu masīvs piemēram [html]<script>var masivs=new Array();masivs[1]=new Array();masivs[1][1]="152";masivs[1][2]="718";masivs[1][3]="543";masivs[1][4]="466";masivs[1][5]="921";masivs[2]=new Array();masivs[2][1]="Pirmais";masivs[2][2]="Otrais";masivs[2][3]="Trešais";masivs[2][4]="Ceturtais";masivs[2][5]="Piektais";</script>[/html] Link to comment Share on other sites More sharing options...
indoom Posted July 17, 2008 Report Share Posted July 17, 2008 (edited) var s = document.getElementById('selecta_id'); for(var i=0,e=s.options,l=e.length,masivs=[null,[],[]];i<l;++i){ masivs[1].push(e[i].value); masivs[2].push(e[i].text); } Edited July 17, 2008 by indoom Link to comment Share on other sites More sharing options...
Mikijs Posted July 17, 2008 Author Report Share Posted July 17, 2008 Paldies ;) Link to comment Share on other sites More sharing options...
Recommended Posts