stevend Posted August 10, 2008 Share Posted August 10, 2008 Hi,Can anyone help me with the following code please.Not sure what I am doing wrong. var teamerror=false;for (var i = 0; i < 11; i++){ el = document.getElementById("team" + i); var firstteam=el.value; var teamsame=1; for (var j = 0; j < 11; j++){ el2=document.getElementById("team"+j); var secteam=el2.value; if (i!=j){ if (secteam=firsteam){ teamsame=teamsame+1; } if(teamsame=3){ teamerror=true; } } }}alert(teamerror); ThanksSteve Link to comment Share on other sites More sharing options...
Ingolme Posted August 10, 2008 Share Posted August 10, 2008 The reason your code isn't working is because you're using an assigning operator on these lines:if (secteam=firsteam){if(teamsame=3)You have to use a comparative operator:if (secteam == firsteam){if(teamsame == 3)You could simplify this line:teamsame=teamsame+1;to this:teamsame++ Link to comment Share on other sites More sharing options...
stevend Posted August 10, 2008 Author Share Posted August 10, 2008 Superb,I have been trying all kinds of things for days with no luck but that works superbly now, something as simple as that is so difficult when you dont quite know the correct syntax.ThanksSteve Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.