当前位置: 代码迷 >> Web前端 >> 判断一组数中是不是有相等的值如1,2,1,21,3
  详细解决方案

判断一组数中是不是有相等的值如1,2,1,21,3

热度:190   发布时间:2012-10-31 14:37:31.0
判断一组数中是否有相等的值如1,2,1,21,3

<script>
??? function fs()
??? {
??????? var no=document.getElementsByName("invoiceNo");
?
??for(var i=0;i<no.length;i++)
??{
???fss(i,no[i].value);
? ????? }
??? }
???
??? function fss(indexs,val)
??? {
??????? var no=document.getElementsByName("invoiceNo");
??????? for(var v=0;v<no.length;v++)
??????? {
??????????? if(indexs!=v)
??????????? {
??????????????? if(val==no[v].value)
??????????????? {
??????????????????? alert('有相等的值');
??????????????????? return;
??????????????? }
??????????? }
??????? }
??? }
</script>

?

<body>
??? <input name="invoiceNo"/><br>
???? <input name="invoiceNo"/><br>
???? <input name="invoiceNo"/><br>
??????<input name="invoiceNo"/><br>
???????<input name="invoiceNo" /><br>
???????<input type="button" onclick="fs()" value="ck"/>
</body>

  相关解决方案