Mikijs Posted July 17, 2008 Report Share Posted July 17, 2008 Sveiki, vēlos lūgt Jūsu palīdzību atrisināt 1 porblēmu. Man ir HTML kods <select name='cat_list' size='10'> <option value='35'>Pirmais</option> <option value='72'>Otrais</option> <option value='26'>Trešais</option> <optgroup legend='Pārējie'></optgroup> <option value='3'>Ceturtais</option> <option value='84'>Piektais</option> <option value='632'>Sestais</option> </select> <select name='func_list' size='10'> </select> Kā lai es dabūnu "ondclick" pārnes no "cat_list" uz "func_list" un otrādi? Link to comment Share on other sites More sharing options...
andrisp Posted July 17, 2008 Report Share Posted July 17, 2008 Uz kura elementa onclick ? Ko nozīmē pārnest ? Link to comment Share on other sites More sharing options...
Mikijs Posted July 17, 2008 Author Report Share Posted July 17, 2008 (edited) Pārnes to <option> uz kura uzkliko no <select> "cat_list" uz <select> "func_list" un otradi Edited July 17, 2008 by Mikijs Link to comment Share on other sites More sharing options...
codez Posted July 17, 2008 Report Share Posted July 17, 2008 http://www.w3schools.com/htmldom/dom_obj_select.asp getElementById() add() remove() selectedIndex Link to comment Share on other sites More sharing options...
andrisp Posted July 17, 2008 Report Share Posted July 17, 2008 (edited) Ar onchange event nolasi izvēlēto vērtību (kā arī option tekstu). Tad ar DOM metodēm izremūvo elementu no viena <select> un ieliec elementu otrā. http://developer.mozilla.org/en/docs/DOM:element#Methods PS. rekā - nemaz nezināju, ka select'am ir tādas īpašas metodes. Edited July 17, 2008 by andrisp Link to comment Share on other sites More sharing options...
Mikijs Posted July 17, 2008 Author Report Share Posted July 17, 2008 Ok mēģināsu .. Paldies Link to comment Share on other sites More sharing options...
Mikijs Posted July 17, 2008 Author Report Share Posted July 17, 2008 tipa sanāk ja nu kādam vaig <script> function change_listing() { var move=document.getElementById("parvietot_no_sejienes").value; // Nosaukums var x=document.getElementById("parvietot_no_sejienes"); // Izdzes x.remove(x.selectedIndex); var y=document.createElement('option'); y.text=move; var x=document.getElementById("parvietot_uz_sejieni"); // Pievieno try { x.add(y,null); } catch(ex) { x.add(y); // IE } } </Script> Link to comment Share on other sites More sharing options...
andrisp Posted July 17, 2008 Report Share Posted July 17, 2008 "Komentāri" vienkārši burvelīgi :) Link to comment Share on other sites More sharing options...
Mikijs Posted July 17, 2008 Author Report Share Posted July 17, 2008 :D :D zinu zinu Link to comment Share on other sites More sharing options...
Grey_Wolf Posted July 17, 2008 Report Share Posted July 17, 2008 Pārnes to <option> uz kura uzkliko no <select> "cat_list" uz <select> "func_list" un otradi Diemzel shads variants nestraadas uz Visiem Brauzeriem ... Testiem parbaudi : IE 6.xx (un nebriinies ka 6.xx Vel sho versiju lieto ~~ 25% useru ...) Skat seit FF 1.5 (2 ?) Opera 8.xxx Safari .... (UZ win tagat arii ir pieejama --> kautgan pagljukaina versija) ------ <select> elemnetu Dinamiska pievienosana/ Staraadaa peec principa Varbuut sanaks... Link to comment Share on other sites More sharing options...
Mikijs Posted July 17, 2008 Author Report Share Posted July 17, 2008 (edited) IE 5 - NEIET IE 6.xx (un nebriinies ka 6.xx Vel sho versiju lieto ~~ 25% useru ...) Skat seit - NEIET FF 1.5 (2 ?) - IET Opera 8.xxx - IET Nja.. ka jau tiko dzirdejam no Gray_Wolf.. ta ir patiesība.. varbūt zināt kadu alternatīvu priekšs IE ? šobrīd mans kods ir aptuveni šāds [html]<script> function change_listing(vars) { if(vars == 1){ from="to"; /*select lauks 2 */ to="from"; /*select lauks 1 */ }else{ from="from"; /*select lauks 1 */ to="to"; /*select lauks 2 */ } var move=document.getElementById(from).value; if(move) { var distant=new Array(); distant[17] = "hj"; distant[18] = "hjhj"; distant[2] = "Interesantie lāsti"; distant[4] = "Pirmie"; distant[13] = "agas"; distant[19] = "gasga"; distant[14] = "as"; distant[5] = "Otrie"; distant[3] = "Kautkādi lāsti"; distant[15] = "gas"; distant[20] = "gas"; distant[6] = "Trešie"; distant[10] = "bjkjljk"; distant[16] = "te"; distant[7] = "Ceturtie"; distant[21] = "jkhj"; distant[9] = "Un vēl"; distant[22] = "hjhkjhkg"; distant[23] = "ugfiugui"; distant[8] = "Vēl"; distant[24] = "guiguigui"; distant[25] = "guigui"; distant[26] = "guigiu"; distant[27] = "guig"; distant[28] = "igui"; distant[29] = "gui"; var x=document.getElementById(from); x.remove(x.selectedIndex); var y=document.createElement('option'); y.text=distant[move]; y.value=move; var x=document.getElementById(to); try { x.add(y,null); } catch(ex) { x.add(y); // IE } } } </Script> <!--[if IE]> <script> function change_listing(vars) { alert('WTF'+vars); } </Script> <![endif]-->[/html] Edited July 17, 2008 by Mikijs Link to comment Share on other sites More sharing options...
indoom Posted July 17, 2008 Report Share Posted July 17, 2008 http://www.mredkj.com/tutorials/tutorial006.html Link to comment Share on other sites More sharing options...
Recommended Posts