Ok I'm making (or trying...) to make a script where I have a number of small pictures which you click on to get an enlarged version (without changing the page). So the idea goes - you click the picture which uses the "onclick" command to access a function to change the variable called "selected". But it isn't returning the new value of selected because I'm not using the "return" command properly... or I've made some screw-up in the loop.
- But I'm sticking with the idea that I'm not returning it properly! I'm not very familiar with javascript so if someone could help me with this then that would be great :)
- But I'm sticking with the idea that I'm not returning it properly! I'm not very familiar with javascript so if someone could help me with this then that would be great :)
<html> <head> <script type="text/javascript"> var selected function change_a(selected) { selected=1 return selected } function change_b(selected) { selected=2 return selected } </script> </head> <body> <image src="image_a.bmp" onclick="change_a(selected)"> <image src="image_b.bmp" onclick="change_b(selected)"> <script type="text/javascript"> if (selected==1) {alert("Image -a- selected")} if (selected==2) {alert("Image -b- selected")} document.write (selected) </script> </body> </html>