james909 Posted July 21, 2013 Share Posted July 21, 2013 Here is my Code, It is a popup to change an image main window, I am trying to get the image to display if image 2,3 or 4 are selected, and no image to display is image 1 is selected. It all works except getting the If statement to check whether image 1 is selected or not: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Select an Armor</title> <link rel="stylesheet" href="selectwindow.css"> <script> (function() { 'use strict'; function removeWindow(){ if(window.name='wxyz'){ var pic=document.getElementById('thumbs').getElementsByTagName('img'); var c=pic.length; while(--c>-1) { pic[c].onclick=function(){ window.opener.document.getElementById('windowc').src=this.src.replace('-thumb',''); window.opener.document.getElementById('windowc').style.display="inline"; if(pic.src=="pics/Image1.png") { window.opener.document.getElementById('a1windowchange').style.display="none"; } window.close(); } } var txt=document.createTextNode('close this window'); var cl=document.createElement('h2'); cl.setAttribute('id','wincl'); cl.appendChild(txt); document.body.appendChild(cl); document.getElementById('wincl').onclick=function(){ window.close(); } } } window.addEventListener? window.addEventListener('load',removeWindow,false): window.attachEvent('onload',removeWindow); function closeme() { window.close(); } window.onblur=closeme; })(); </script> </head> <body> <ul id="thumbs"> <li><img src="pics/Image1.png" alt=""></li> <li><img src="pics/Image2.png" alt=""></li> <li><img src="pics/Image3.png" alt=""></li> <li><img src="pics/Image4.png" alt=""></li> </ul> </body> What is the correct way to code: if(pic.src=="pics/Image1.png") To check whether pics/Image1.png has been selected or not? Quote Link to comment https://forums.phpfreaks.com/topic/280368-javascript-popup-window-changes-display-style-for-different-images/ Share on other sites More sharing options...
.josh Posted July 22, 2013 Share Posted July 22, 2013 shouldn't it be if(pic[c].src=="pics/Image1.png") Quote Link to comment https://forums.phpfreaks.com/topic/280368-javascript-popup-window-changes-display-style-for-different-images/#findComment-1441700 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.