片段一

 

<script type="text/javascript">
//定义数组接受遍历的产品ID
var vable1 = new Array()
//遍历出产品ID
<c:forEach var="b" items="${barcodes}" varStatus="idx" >
	vable1.push(${b.productId})
</c:forEach>

//去除数组中重复数据
function removeDuplicateArray(o){
 var obj={},ret=new Array(),i=0;
 for(var a in o){
 obj[o[a]]=o[a];
 }
 for(ret[i++] in obj);
 return ret;
}
//去除字符串中重复字符
function removeDuplicateString(str){
 var obj={},ret="";
 for(var i=0;i<str.length;i++){
  var s=str.slice(i,i+1);
  obj[s]=s;
  }
 for(s in obj){
  ret+=obj[s];
  };
 return ret;
 }
//去除数组或字符串中的重复字符
function removeDuplicate(o){
 return typeof(o)=="object"?removeDuplicateArray(o):removeDuplicateString(o);
 }

var vable2 = removeDuplicate(vable1);
for(i = 0;i<vable2.length;i++){
<%--$("#proskd").append("<h4>"+vable2[i]+"</h4>");--%>
}

</script>

 

你可能感兴趣的:(片段一)