<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<script language="javascript">
Array.prototype.unique = function () {
var r = new Array();
o:for(var i = 0, n = this.length; i < n; i++){
for(var x = 0, y = r.length; x < y; x++){
if(r[x]==this[i]){
continue o;
}
}
r[r.length] = this[i];
}
return r;
}
function doArrayUnique(){
var myfrm = document.getElementById("myfrm");
var myary = new Array();
for(var i=0;i<myfrm.elements.length;i++){
if (myfrm.elements[i].id=='num[]'){
myary[i] = myfrm.elements[i].value;
}
}
alert(myary);
var unique = myary.unique();
alert(unique);
}
</script>
<form id="myfrm" onsubmit="return doArrayUnique()();">
<?
for($i=0;$i<5;$i++){
echo "<input type=\"text\" name=\"num[]\" id=\"num[]\" /><br>";
}
?>
<input type="submit" />
</form>
</body>
</html>