Nuimi Posted April 13, 2015 Share Posted April 13, 2015 (edited) Can you help me with function zmen. I need change picture after click. (click one x.jpg, click two o.jpg, click three x.jpg, click four o.jpg, ...) <script type="text/javascript"> hodnoty = ['img/nic.png','img/x.jpg','img/o.jpg']; hrac = 2; hrac1 = hrac ? 1 : 2; function zmen(img,hrac) { if(hrac < 1) { img.src = (img.src!=hodnoty[0]) ? hodnoty[hrac] : hodnoty[0]; } else { img.src = (img.src!=hodnoty[0]) ? hodnoty[hrac1] : hodnoty[0]; } } function reset(img,hrac) { var im, ob, i; ob = document.getElementById('pole'); im = ob.getElementsByTagName('img'); for(i=0;i<im.length;i++) { zmen(im[i],0); } } </script> Edited April 13, 2015 by Nuimi Link to comment Share on other sites More sharing options...
justsomeguy Posted April 13, 2015 Share Posted April 13, 2015 The value of hrac never changes once the code starts. Move the code to change that value inside the function. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now