读书人

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

发布时间: 2012-10-31 14:37:31 作者: rapoo

判断一组数中是否有相等的值如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>

读书人网 >Web前端

热点推荐