Kristabs Posted March 4, 2006 Report Share Posted March 4, 2006 Man pasham sanaaca tikai, ja visiem checkboxiem ir vienaads 'name'... Var kaads paraadiit piemeeru, kaa atkjekseet visus checkboxus ar vienas pogas paliidziibu? Vai nu noteiktas formas visus checkboxus, vai arii visus, kuriem name="sample[]" ... Paldies jau ieprieksh! Link to comment Share on other sites More sharing options...
bubu Posted March 4, 2006 Report Share Posted March 4, 2006 Man pasham sanaaca tikai, ja visiem checkboxiem ir vienaads 'name'... ... vai arii visus, kuriem name="sample[]" wtf? var elems = document.getElementsByName("sample[]"). for (var i=0, count=elems.length; i<count; ++i) { elems[i].checked = true; } A ja nu vajag "Vai nu noteiktas formas visus checkboxus", tad: var elems = document.getElementById("formas_id").getElementsByTagName("input"); for (var i=0, count=elems.length; i<count; ++i) { if (elems.type=="checkbox") { elems[i].checked = true; } } Link to comment Share on other sites More sharing options...
Kristabs Posted March 4, 2006 Author Report Share Posted March 4, 2006 (edited) http://paste.php.lv/3373 Es kautko ne tā? Man rāda, ka funkcijas nav definētas. Nesaprotu kāpēc http://paste.php.lv/3375 straadaa, bet http://paste.php.lv/3373 nestraadaa ?? Edited March 4, 2006 by Kristabs Link to comment Share on other sites More sharing options...
bubu Posted March 4, 2006 Report Share Posted March 4, 2006 Man pašam jāuzmin, kuras funkcijas nav definēta? Uzliec tak debugeri (ja IE, tad microsoft script debugger, ja FF tad Venkman, vai pat ar parasto JS konsoli) un pats redzēsi kurā vietā apstājas kods, un varēsi variabļu vērtības paskatīties tak! Eh.. pēdējo reizi minu, nākamreiz neminēšu. No tava koda: <form name="formcheck" var elems = document.getElementById(frm) Atšķirību starp name un id zini un redzi? Es tak skaidri un gaiši savā piemērā uzrakstīju: var elems = document.getElementById("formas_id"). Nevis formas_name. Link to comment Share on other sites More sharing options...
Kristabs Posted March 4, 2006 Author Report Share Posted March 4, 2006 Saliku pareizi id, nevis name - vienalga neiet, man aizgaaja taa pirmaa funkcija, kur jaanoraada name, tur tikai viena punkta vietaa jaaieliek semikols. Vienkaarshi bija sintakses kljuuda un console saka, ka funkcija nav defineeta. Tagad viss kaartiibaa. Link to comment Share on other sites More sharing options...
bubu Posted March 4, 2006 Report Share Posted March 4, 2006 Apgaismo mani, kura punkta vietā jāliek semikols? Link to comment Share on other sites More sharing options...
Kristabs Posted March 4, 2006 Author Report Share Posted March 4, 2006 var elems = document.getElementsByName("sample[]"). <-- for (var i=0, count=elems.length; i<count; ++i) { elems.checked = true; } Link to comment Share on other sites More sharing options...
bubu Posted March 4, 2006 Report Share Posted March 4, 2006 ah.. ok, nemaz nepamanīju. Link to comment Share on other sites More sharing options...
Kristabs Posted March 6, 2006 Author Report Share Posted March 6, 2006 Strādājošs piemērs, gan jau vēl kādam noderēs. http://paste.php.lv/3389 Link to comment Share on other sites More sharing options...
Recommended Posts