Sinisterly
Java script - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Design (https://sinister.ly/Forum-Design)
+--- Forum: Web Design (https://sinister.ly/Forum-Web-Design)
+--- Thread: Java script (/Thread-Java-script)



Java script - 1MrE1 - 04-11-2014

Code:
<script> function changeimage() { element = document.getElementById('bulbon'); if (element.src.match("http://www.w3schools.com/js/pic_bulbon.gif")) { element.src = "http://www.w3schools.com/js/pic_bulboff.gif"; } else { element.src = "http://www.w3schools.com/js/pic_bulbon.gif"; } } </script> <script> function changeimage1() { element = document.getElementById('bulbons'); if (element.src.match("http://www.w3schools.com/js/pic_bulbon.gif")) { element.src = "http://www.w3schools.com/js/pic_bulboff.gif"; } else { element.src = "http://www.w3schools.com/js/pic_bulbon.gif"; } } </script> <img src="http://www.w3schools.com/js/pic_bulboff.gif" id="bulbon" onclick="changeimage()" width="150" height="150"<t>> <img src="http://www.w3schools.com/js/pic_bulboff.gif" id="bulbons" onclick="changeimage1()" width="150" height="150">
/* i wrote this script now i want to add a script that if both bulbs are on the image of the background changes and vice versa can you help me please */
//i would be very thankfull


RE: need some help - chmod - 04-11-2014

Use code tags for code I've edited it for you this time but in future I expect you to do this yourself.


RE: need some help - 1MrE1 - 04-11-2014

thank but i would appreciate your help in the program itself if you might ))


RE: need some help - The Real Slim Shady - 04-11-2014

I dont do javascript really, but I dont see why you wouldnt do something like

Code:
element = document.getElementById('bulbons'); element2 = document.getElementById('bulbons2'); if (element.src.match("http://www.w3schools.com/js/pic_bulbon.gif") && element2.src.match("http://www.w3schools.com/js/pic_bulbon.gif"))

And obviously fix the rest of the code to reflect the same changes. You'll obviously need to create a second element called bulbons2


RE: need some help - 1MrE1 - 04-11-2014

yep now i know what i have to do thank you very much :HeartEyes: