如何创建两个单独的列表并显示它们?

时间:2019-06-08 12:14:28

标签: javascript html variables

我正在为比赛选择团队选择器,我需要做的是使每个团队拥有相等数量的玩家,并且如果该人姓名旁边的下拉值框与另一个人相同,他们将自动进入不同的团队。最后,我需要它来显示两个团队。

我一直在尝试使用“ =”作为下拉菜单,并根据事物是否相等提供两个不同的事件

这是我一直在使用的JavaScript。底部的功能并不完整,因为需要进行的工作是搜索所有播放器以找到匹配的标签并将它们分开。这是代码:

var teamgreen = ["1","2","3","4","5","6","7","8","9","10"];
var teamblue = ["1","2","3","4","5","6","7","8","9","10"];
var no1 = document.getElementById('nosameteamplayer1').value;
var no2 = document.getElementById('nosameteamplayer2').value;
var no3 = document.getElementById('nosameteamplayer3').value;
var no4 = document.getElementById('nosameteamplayer4').value;
var no5 = document.getElementById('nosameteamplayer5').value;
var no6 = document.getElementById('nosameteamplayer6').value;
var no7 = document.getElementById('nosameteamplayer7').value;
var no8 = document.getElementById('nosameteamplayer8').value;
var no9 = document.getElementById('nosameteamplayer9').value;
var no10 = document.getElementById('nosameteamplayer10').value;
var no11 = document.getElementById('nosameteamplayer11').value;
var no12 = document.getElementById('nosameteamplayer12').value;
var no13 = document.getElementById('nosameteamplayer13').value;
var no14 = document.getElementById('nosameteamplayer14').value;
var no15 = document.getElementById('nosameteamplayer15').value;
Function; makeFunction(); {
  if (no1 === no2) {
teamgreen[0] = document.getElementById('player1nametext').text;
teamblue[0] = document.getElementById('player2nametext').text;
} else {
teamgreen[0] = document.getElementById('player1nametext').text;
teamgreen[0] = document.getElementById('player2nametext').text;        
}
}

nosameteamplayer ID是带有字母的下拉列表,并且该下拉列表的HTML如下:

<select id="nosameteamplayer1" name="nosameteamplayer1">
  <option value="A">A</option>
  <option value="B">B</option>
  <option value="C">C</option>
  <option value="D">D</option>
  <option value="E">E</option>
  <option value="F">F</option>
  <option value="G">G</option>
  <option value="-">-</option>
</select>```

0 个答案:

没有答案