lundi 18 mai 2015

Trouble with multi-parameter if statement

I have some basic HTML and JavaScript that will allow a user to click on one image of four images per each question that applies to them (a survey). Then, based on which two images the user clicked on, a link will be generated to rout them to another page. I decided that the easiest way to achieve this function would be through a series of 'if-statements' and making the clicked image ids 'false'.

However my issue is: I can get each individual false statement to work, but the combined statement will not trigger the alert.

my HTML:

<div id="page3">
<h1 align="right">generally i feel</h1>
   <img src="../Images/tile1.png" id="tile1" value="1"/>
   <img src="../Images/tile2.png" id="tile2" value="2"/>
   <img src="../Images/tile3.png" id="tile3" value="3"/>
   <img src="../Images/tile4.png" id="tile4" value="4"/>
</div>

<div id="page4">

<h1 align="right">i see</h1>
   <img src="../Images/ink.png" id="ink">
   <div id="pg4ans">
       <img src="../Images/tile5.png" id="tile5" class="tile2">
       <img src="../Images/tile6.png" id="tile6" class="tile2">
       <img src="../Images/tile7.png" id="tile7" class="tile2">
       <img src="../Images/tile8.png" id="tile8" class="tile2">
   </div>

</div>

my Script:

var dest1 = document.getElementById("tile1");
var dest5 = document.getElementById("tile5");

$('#tile1').click(function(){
    dest1 = false;
});

$('#tile5').click(function(){
    dest5 = false;
});

if(dest1 = false, dest5 = false){
    alert("link will replace this alert");  

}

Of course, if there is a simpler way to achieve this effect, that would be great too.

Aucun commentaire:

Enregistrer un commentaire