Rich Bitch Posted June 27, 2008 Report Share Posted June 27, 2008 (edited) js kods, kas nestraadaa un kur nesaprotu kljuudu: function sum() { var summa = 0; var i = 0; var vertiba = 0; for (i=1;i<=10;i++) { vertiba = document.getElementById('a['+i+']').value; summa=summa+vertiba; } document.write(summa); } Edited June 27, 2008 by Rich Bitch Link to comment Share on other sites More sharing options...
indoom Posted June 27, 2008 Report Share Posted June 27, 2008 pamēģini summa=summa+parseInt(vertiba,10); Link to comment Share on other sites More sharing options...
andrisp Posted June 29, 2008 Report Share Posted June 29, 2008 ID nevar satureet [ un ]. Visticamaak, ka tur arii kljuuda. Link to comment Share on other sites More sharing options...
bubu Posted June 29, 2008 Report Share Posted June 29, 2008 andrisp: tas, ka nevar, tas nenozīmē, ka tas nestrādās :) HTML dokuments arī "nedrīkst" saturēt vairākus elementus ar vienādiem id. ar [ un ] nevajadzētu šeit būt problēmām. Rich Bitch: tu saki, ka nesaproti kļūdu. A kādu kļūdu saka vai rāda? Link to comment Share on other sites More sharing options...
indoom Posted June 29, 2008 Report Share Posted June 29, 2008 Bez tam, nez vai būtu gudri likt funkcijā document.write() http://javascript.about.com/library/blwrite.htm Pārbaudi vai HTMLā ir visi 10 formas elementi ar ID, kādi tiek meklēti funkcijā piem, id="a[1]", id="a[2]", ... id="a[10]". Ja kaut viens no tiem 10 trūks, tad būs JS errors un kods neizpildīsies. Link to comment Share on other sites More sharing options...
Recommended Posts