Alnis Posted March 18, 2009 Report Share Posted March 18, 2009 Tatad esmu uzskricelejis javascripta kodinu, viss strada labi ieks IE, bet nestrada ne Opera, ne Firefox :) Kadi butu ieteikumi, kaa rakt, lai kodu piemerotu ari siem browseriem. Nu varbut ir kadas error consoles utt, kas konkreti parada kur gluks? Paldies P.S. javascripts ir ieslegts, bet kodu izpilda daleji Quote Link to comment Share on other sites More sharing options...
0 bubu Posted March 18, 2009 Report Share Posted March 18, 2009 Vispirms sāc ar to, ka atrodi konkrētu vietu kodā, kur notiek kļūda un viss apstājas. Tam lieto JS debugeri, vai vienkāršākajā gadījumā pats jau pateici - error konsoli. Firefoksim to atver ar Ctrl+Shift+J (zem Tools meņu). Kad atradsīsi konkrēto vietu, tad pārbaudi mainīgo vērtības - vai tās atbilst tam, ko sagadi. Utt. Quote Link to comment Share on other sites More sharing options...
0 Alnis Posted March 18, 2009 Author Report Share Posted March 18, 2009 (edited) ok, paldies. pafichosu, ja netiksu jeegaa, naksu seit jau ar konkretu koda gabalu! Edited March 18, 2009 by Alnis Quote Link to comment Share on other sites More sharing options...
0 Grey_Wolf Posted March 19, 2009 Report Share Posted March 19, 2009 Ljoti liels procents, ka ir tiiraa Sintakses kljuda , paskaties vai kautkur nav Lielie mazie burti jo JS uz tiem dazos brauzesos ir juutiigs pemeram: getElementById() // pareizi Getelemntbyid() // nepareizi Quote Link to comment Share on other sites More sharing options...
0 werd Posted March 19, 2009 Report Share Posted March 19, 2009 Ljoti liels procents, ka ir tiiraa Sintakses kljuda , paskaties vai kautkur nav Lielie mazie burti jo JS uz tiem dazos brauzesos ir juutiigs pemeram: getElementById() // pareizi Getelemntbyid() // nepareizi Arī man pirmā domā bija par sintakses kļūdu! Ieteiktu jebkurā gadījumā rakstīt pareizu(getElementById) kodu, tas dos tev garantu, ka sintakses kļūdas nebūs! Quote Link to comment Share on other sites More sharing options...
0 Alnis Posted March 20, 2009 Author Report Share Posted March 20, 2009 (edited) Ljoti liels procents, ka ir tiiraa Sintakses kljuda , paskaties vai kautkur nav Lielie mazie burti jo JS uz tiem dazos brauzesos ir juutiigs pemeram: getElementById() // pareizi Getelemntbyid() // nepareizi nebija vel laika skatities tas error consoles, uz atram shaibam paskatijios- ja getElementById man ir papilnam, bet visur pareizi sarakstiti. drosi vien ka bus citas sintakses kludas, jameklee, jameklee.... Edited March 20, 2009 by Alnis Quote Link to comment Share on other sites More sharing options...
0 bubu Posted March 20, 2009 Report Share Posted March 20, 2009 Apskaties tai error konsolē, vai jebkurā sakarīgā JS debugerī - tad uzreiz redzēsi jebkādas sintakses vai neeksistējošu mainīgo vai null vērtību utml kļūdas. Quote Link to comment Share on other sites More sharing options...
0 fest Posted March 20, 2009 Report Share Posted March 20, 2009 Operai error console atverās no Tools->Advanced->Error console. Un dari kā saka bubu- atver konsoli un redzēsi, kur ir kļūda. Laiks pārskatīt visu kodu bija, a pāris klikšķus nospiest- nebija? Quote Link to comment Share on other sites More sharing options...
0 Alnis Posted March 20, 2009 Author Report Share Posted March 20, 2009 (edited) Laiks pārskatīt visu kodu bija, a pāris klikšķus nospiest- nebija? noper mani :D mja, konsole met kludas... sakiet vai seit ir kada atskiriba formas nosaukuma nodosanai uz formulu- tipa viens variants this.form un otrs rakstot konkreti formas nosaukumu? <javascript> mana_formula(form, i) { var kaukaskaukas = (form.bla.value); ... } </javascript> <form name=forma2 id=forma2> <select name="bla" id="bla" onChange="mana_formula(this.form, 1)"> <option></option><option></option><option></option> </select> </form> un <javascript> mana_formula(form, i) { var kaukaskaukas = (form.bla.value); .... } </javascript> <form name=forma2 id=forma2> <select name="bla" id="bla" onChange="mana_formula('forma2', 1)"> <option></option><option></option><option></option> </select> </form> Edited March 20, 2009 by Alnis Quote Link to comment Share on other sites More sharing options...
0 bubu Posted March 20, 2009 Report Share Posted March 20, 2009 otrajā gadījumā tu stringam 'forma2' gribi tikt klāt bla atribūtam. Stringam nav un nekad nav bijis tāds atribūts. Daudz labāk ir formas elementiem piešķirt id atribūtus, un tad to vērtībām piekļūt ar getElementById palīdzību. Quote Link to comment Share on other sites More sharing options...
0 Alnis Posted March 20, 2009 Author Report Share Posted March 20, 2009 (edited) vai sita? <javascript> mana_formula(form, i) { //var kaukaskaukas = (form.bla.value);// nepareizi var kaukaskaukas = form.getElementById("bla").value; //pareizi ... } </javascript> Edited March 20, 2009 by Alnis Quote Link to comment Share on other sites More sharing options...
0 bubu Posted March 20, 2009 Report Share Posted March 20, 2009 Nu tā ar var. Biežāk to getElementById lieto globāli - document objektam, jo id ir unikāls visā dokumentā: var kaukaskaukas = document.getElementById("bla").value; Un vēl biežāk lieto gatavu JS freimworku ar $ funkciju (jeb uzraksta paši tādu): $ = function(elem) { return document.getElementById(elem); } var kaukaskaukas = $("bla").value; Quote Link to comment Share on other sites More sharing options...
0 Alnis Posted March 20, 2009 Author Report Share Posted March 20, 2009 (edited) document.getElementById("bla") is NULL tas nozime, ka vertibas nav vai nav tada formas atributa id="bla"? ka var veikt parbaudi vai ir tads atrubuts vai nav? Edited March 20, 2009 by Alnis Quote Link to comment Share on other sites More sharing options...
0 bubu Posted March 20, 2009 Report Share Posted March 20, 2009 Tas nozīmē, ka tāds HTML elements ar id vērtību "bla" tavā HTML kodā nav atrodams. Quote Link to comment Share on other sites More sharing options...
0 Alnis Posted March 20, 2009 Author Report Share Posted March 20, 2009 (edited) Tas nozīmē, ka tāds HTML elements ar id vērtību "bla" tavā HTML kodā nav atrodams. pasaki, ludzu, ka ar javascripta palidzibu var parbaudit vai tad elements ir mana htmla EDIT: pats atradu atbildi :) if(document.getElementById("bla")) { .... } else { // neeksistee } Edited March 20, 2009 by Alnis Quote Link to comment Share on other sites More sharing options...
0 Alnis Posted March 22, 2009 Author Report Share Posted March 22, 2009 (edited) ko nozīmē: Warning: Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead. ? Edited March 22, 2009 by Alnis Quote Link to comment Share on other sites More sharing options...
Question
Alnis
Tatad esmu uzskricelejis javascripta kodinu, viss strada labi ieks IE, bet nestrada ne Opera, ne Firefox :)
Kadi butu ieteikumi, kaa rakt, lai kodu piemerotu ari siem browseriem. Nu varbut ir kadas error consoles utt, kas konkreti parada kur gluks?
Paldies
P.S. javascripts ir ieslegts, bet kodu izpilda daleji
Link to comment
Share on other sites
25 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.