xfr33 Posted September 14, 2008 Report Share Posted September 14, 2008 Labdien! Lieta tāda ka ir menu un vēlos lai tad kad uzspiež uz kādas menu pogas nomainas div saturs. Domāju tas ir jādara ar javascriptu. Kāds varētu iemest kādu labu tutorialu? :) Link to comment Share on other sites More sharing options...
martins256 Posted September 14, 2008 Report Share Posted September 14, 2008 javascript innerhtml tutorial un "Es ticu veiksmei!" Link to comment Share on other sites More sharing options...
xfr33 Posted September 14, 2008 Author Report Share Posted September 14, 2008 ideāli :) martin paldies :D Link to comment Share on other sites More sharing options...
xfr33 Posted September 14, 2008 Author Report Share Posted September 14, 2008 viens jautājums, kas neatbilst topika nosaukumam :) ir kāds veids ar javascriptu, lai izdarītu kko tādu: trīs teksta laukumos saraksta ciparus, visu pareizina ar 8 (šis ir automatizēts) un uzspiežot pogu parādas kā parasts teksts vai arī kā value citā teksta laukā? Ja ir tad kādu tutorialu var pateikt? :) Link to comment Share on other sites More sharing options...
martins256 Posted September 14, 2008 Report Share Posted September 14, 2008 getelementbyid value tutorial un "Es ticu veiksmei!" Link to comment Share on other sites More sharing options...
xfr33 Posted September 14, 2008 Author Report Share Posted September 14, 2008 ok, bet tur neiet cauri rezināšana ar skaitli, kam ir komats :) Link to comment Share on other sites More sharing options...
martins256 Posted September 14, 2008 Report Share Posted September 14, 2008 Ar punktu arī neiet? Man liekas, ka tur kaut kam jābūt atkarīgam no datora konfigurācijas (vismaz man bij izvēle izmantot . vai ,). Link to comment Share on other sites More sharing options...
xfr33 Posted September 14, 2008 Author Report Share Posted September 14, 2008 nu man ne ar punktu ne ar komatu :) rezultāts sanāk 0 abos gadījumos! Link to comment Share on other sites More sharing options...
martins256 Posted September 14, 2008 Report Share Posted September 14, 2008 parseFloat() parseint() vietā jāliek. Link to comment Share on other sites More sharing options...
xfr33 Posted September 14, 2008 Author Report Share Posted September 14, 2008 čali, tu esi ģēnijs :D varbūt izpalīdzēsi un paskaidrosi kādēļ man neiet onmouseout? :D <html> <head><title>JavaScript</title> <script type="text/javascript"> function changeText(){ document.getElementById('divs').innerHTML = '<img src="http://samueljscott.files.wordpress.com/2007/04/homer_simpson.jpg" width="300px" height="400px">'; } function changeText2(){ document.getElementById('divs').innerHTML = '<img src="http://z.about.com/d/animatedtv/1/0/4/m/simp2006_Marge_f.jpg" width="300px" height="400px">'; } function changeText3(){ document.getElementById('divs').innerHTML = '<img src="http://www.simpsoncrazy.com/gallery/simpsons/LisaSimpson10.gif" width="300px" height="400px">'; } function changeText4(){ document.getElementById('divs').innerHTML = '<img src="http://turmad2.wdfiles.com/local--files/start/Bart_Simpson.png" width="300px" height="400px">'; } </script> <script language="javascript"> function addNumbers() { var val1 = parseFloat(document.getElementById("value1").value); var val2 = parseFloat(document.getElementById("value2").value); var val3 = parseFloat(document.getElementById("value3").value); var ansD = document.getElementById("answer"); ansD.value = val1 * val2 * val3 * 8; } </script> </head> <body> <div id="divs" style="width: 300px; border-style: double; background-color: green; position: absolute; left: 500px;"><img src="http://turmad2.wdfiles.com/local--files/start/Bart_Simpson.png" width="300px" height="400px"/></div> <input type='button' onclick='changeText()' value='Homērs'/> <br/><input type='button' onclick='changeText2()' value='Mārdža' /> <br/><input type='button' onclick='changeText3()' value='Liza' /> <br/><input type='image' src='http://www.axialis.com/objects/ip_icon_03_ButtonDown.png' onclick='changeText4()' onmouseover="document.getElementById('mouse').src='http://www.axialis.com/objects/ip_icon_03_ButtonDown.png'; return true;" onmouseout="document.getElementById('mouse').src='http://www.widearea.co.uk/designer/images/next.gif'; return true;/> <br/><input type='image' src='http://www.widearea.co.uk/designer/images/next.gif' id='mouse'> <div style="border-style: double; position: absolute; top: 600px;"> <br/>Garums <input type="text" id="value1" name="value1" value="1"/> <br/>Platums <input type="text" id="value2" name="value2" value="2"/> <br/>Biezums <input type="text" id="value3" name="value3" value="3"/> <br/><input type="button" name="Sumbit" value="Aprēķināt" onclick="java script:addNumbers()"/> <br/>Atbilde <input type="text" id="answer" name="answer" value=""/> </div> <br/><input type='image' src='http://www.widearea.co.uk/designer/images/next.gif' id='mouse'> </body> </html> viss ir samests nežēlīgi haotiski, bet tas tikai izmēģinājums, lai saprastu kā viss darbojas :) Link to comment Share on other sites More sharing options...
martins256 Posted September 14, 2008 Report Share Posted September 14, 2008 (edited) Īstenībā es JS nemāku. bet man liekas, ka .src=... varētu neeksistēt. Es ietektu arī izmantot kkādu jquery, lai tās lietas ritētu raitāk. P.S. es nesen tieši tādu lietu taisīju ar mouse on/out+bildes mainīšanu. Un piefiksēju, ka tiek bilde lādēta katru reizi. Tāpēc iesaku šo problēmu risināt ar css+JS Edited September 14, 2008 by martins256 Link to comment Share on other sites More sharing options...
xfr33 Posted September 14, 2008 Author Report Share Posted September 14, 2008 martin, ne kur nu :) nemāki :D lab pieņemsim. src eksistē un ir tāds pats ka pirms uzbraukšanas. tjip ir bilde uz kuras uzbrauc un bilde nomainās. nobrauc nost un bilde paliek iepriekšējā :) Link to comment Share on other sites More sharing options...
xfr33 Posted September 14, 2008 Author Report Share Posted September 14, 2008 un man radās vēl viens jautājums :) man tgd ir viens text boxs kurā parādas atbilde, bet ja es vēlos lai atbilde parādas nevis text boxā, bet gan kā parasts teksts? :) kas tad ir jāmaina? Link to comment Share on other sites More sharing options...
bubu Posted September 14, 2008 Report Share Posted September 14, 2008 Nelieto tad textboxi. Lieto parastu html elementu (div, span, p, whatever), kuram ar to pašu innerHTML maini saturu. Link to comment Share on other sites More sharing options...
xfr33 Posted September 14, 2008 Author Report Share Posted September 14, 2008 bubu, es nedaudz nesapratu. Nu es to input text nomainīju par span tagu, bet atbildi man nemet ārā. viens kods: var ansD = document.getElementById("answer"); un tas span tags <br/>Atbilde ir <span id="answer" name="answer"></span>! kas ir nepareizi? Link to comment Share on other sites More sharing options...
Recommended Posts