Vebers Posted March 16, 2006 Report Share Posted March 16, 2006 No JS daudz es neko nesaprotu , tapec ari tads muljkiigs jautaajums. Piemeram, man ir poga/text uz kura ar onclick tiek nomainita lapaa redzamaa bilde (tjip galerija), itkaa ar php es JS vareetu padod visus attiecigos URLjus, katrai bildei, aprakstu utml, bet nu kaa lai es panaku to, ka nospiezhot uz shis pogas/texta nomainas bilde? ... <html> <head> <script> function ChangeImage() { var URLs = new Array(); URLs[1] = 'images/smdng4464626.jpg'; URLs[2] = 'images/hahsrg346lvbmnl.jpg'; document.getElementById('image').src=URLs[1]; return true; } </script> </head> <body> <div> <span id="next" onclick="ChangeImage()">» Talak</span> <div><img id="image" src="images/loading.gif" alt="bilde"/></div> </div> </body> </html> Shaadi es itka maku dabbut, lai nomainas pirma bilde, bet nemaku uztaisit to "next". Varat palidzet? Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 16, 2006 Report Share Posted March 16, 2006 MakaTaNaw--> labi ruupiigi pameklee sheit pat forumaa :) kautkad biju ieposteejis kodu kas ljau ar JS meniit bildes :) iepieksh taas ielaadeejot atminjaa ... P.S. 'Vajag tik rakt' :) Link to comment Share on other sites More sharing options...
Vebers Posted March 16, 2006 Author Report Share Posted March 16, 2006 (edited) rekur ir links, atradu. http://paste.php.lv/3460 Bet man kaut kas nedarbojas - nekaadas reakcijas. Bet nu sis neatrisina manu problemu, jo katru reizi "next" pogai bus janorada dati (bildes nosaukums un url), ko es protams ar JS neparladejot lapu nemaku. Ideja ir tadi pati, ka draugiem.lv skatoties kada drauga fotogaleriju. Jauki mainas bildes, spaidot pogas talak/atpakal. P.S. Kapec tev tik daudz postu? Nebija viegli atrast :D. Ieprieksh izskreju cauri visai JS sadaljai, bet biju paskrejis garam shim postam. Edited March 16, 2006 by MakaTaNaw Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 16, 2006 Report Share Posted March 16, 2006 (edited) nush kur probleema ? 'bildes_obj_nosaukums_'+mainigais; un nospiezot uz next palielini mainiigais par 1 uz back samazini par 1 ;) tik neaizmirsti parbaudiit vai nav 0 un vai nav sasniegts maksimums... veidojot datus ar PHP raksti ciklaa (cik vien taas bildes veelies) for ($i=0; $i<cik_bildes+1; $i) { echo 'preload("bildes_objekts_"'.$i.',"bilde no db vai vienalga no kurienes")' } -------- kur probleema? Edited March 16, 2006 by Grey_Wolf Link to comment Share on other sites More sharing options...
Vebers Posted March 16, 2006 Author Report Share Posted March 16, 2006 problema ir tur, ka es nejedzu uztaisit (parveidot) taa , ka lai uzklikojot uz pogas next pieskaititotos tas 1 :) Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 16, 2006 Report Share Posted March 16, 2006 (edited) <script> var skaitiitaajs=0; function blah(a) { a=a+1; return a; } <script> <a href="java script:void(0)" onclick="skaititajs=blah(skaititajs)">next</a> edit: neaizmirsti ka f-jas iekspusee var izsaukt citu f-ju ;) Edited March 16, 2006 by Grey_Wolf Link to comment Share on other sites More sharing options...
Vebers Posted March 16, 2006 Author Report Share Posted March 16, 2006 (edited) Ahh.. prieks ka sanaca :) Paldies! Bet varbut pie reizes vari man paskaidrot, ko nozime java script:void(0). Cik zinu, tas java script: noraada, ka tiks izmantots javaskripts :) , bet kas ir tas void(0) ? Edit: mja, tikko izlasiju tavu "editu" , bet jau atkodu to , xe (to ieprieks nezinaju) Edited March 16, 2006 by MakaTaNaw Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 16, 2006 Report Share Posted March 16, 2006 void(0) apmeerm to pahu ko NULL ;) tikpat labi vareetu : <a href="#" onclick=".... tik shajaa gadijumaa tiktu mekleets # 'enkurs' ar void(0) netiek mekleets nekas un kljuudu arii netgriezj... Apmeeram taa... Ja intresee siikaak pameklee Ineta ;) Link to comment Share on other sites More sharing options...
Vebers Posted March 16, 2006 Author Report Share Posted March 16, 2006 Skaidrs. Un veelreiz paldies, xe. Vismaz sodien ko ljoti derigu sev busu iemacijies. Link to comment Share on other sites More sharing options...
Vebers Posted March 16, 2006 Author Report Share Posted March 16, 2006 Un vel jautajums: Ka ar JS var izskaitit cik tas bildes atminja ir ieladetas? :) Tas parbaudei, prieksh next pogas. Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 16, 2006 Report Share Posted March 16, 2006 (edited) kaadeelj tas buutu jaaskaita ar JS? ja to laadee ciklaa tu tachu zinaasi cik ielaadee? PHP: cils kas tev iizvada taas bildes ar preload.... un beigaas echo 'var kopabildes='. $cik_nu vinju_bija.';'; nezizmirsti izvadiit zemikolu !!! Edited March 16, 2006 by Grey_Wolf Link to comment Share on other sites More sharing options...
Vebers Posted March 16, 2006 Author Report Share Posted March 16, 2006 Nez, nemaz neiedomajos par PHP risinajumu, pie JS genereshanas. Laikam JS mani parnjemis ar savu "atrumu" :) Ok, centisos neaizmirst, bet JS funkcijas tie mainigie ir globaali? piem., es vinjus varu izsaukt taa: var a=1; function sum(b) { return a+b; } sum(2); Vai vinji ir jaregjistree ka php (global)? ka tas notiekas? Link to comment Share on other sites More sharing options...
bubu Posted March 16, 2006 Report Share Posted March 16, 2006 Nē, nav jāreģistrē. Šai situācijā JS darās tāpat kā paskāls - skatās mainīgos vispirms lokāli, pēc tam vienu līmeni augstāk utt līdz globālajam līmenim. Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 16, 2006 Report Share Posted March 16, 2006 (edited) vinji ir globaali ja tiek defineeti arpus f-jas ;) vai nosaciiti globaali ja ieksh f-jas (manaa piemeeraa lokalais_mainiigais darbosies tikai tad ja f-ja blah2() tiks isaukta no f-jas blah() ) piem: <script> var globals_mainiigais=9999; function blah(globals_mainiigais) { var lokaals_mainiigais=5000; blah2(globals_mainiigais, lokaals_mainiigais) } function blah2(a,b) { alert(a); alert(b); } blah(globals_mainiigais); </script> apskaties pats kaads buus rez :) nus apmeeram taa:) edit: bubu pakaidroja labaak :) Edited March 16, 2006 by Grey_Wolf Link to comment Share on other sites More sharing options...
Vebers Posted March 16, 2006 Author Report Share Posted March 16, 2006 O skaidrs, paldies. Link to comment Share on other sites More sharing options...
Recommended Posts