Prototype Function
<!-- Script by hscripts.com -->
<!-- copyright of HIOX INDIA -->
<!-- Free javascripts @ http://www.hscripts.com -->
<script language=javascript>
Array.prototype.sort = function()
{
for(i=0;i<this .length;i++)
{
for(j=i+1;j<this.length;j++)
{
if(Number(this[i]) >Number(this[j]))
{
temp = this[j];
this[j] = this[i];
this[i] = temp;
}
}
}
}
Array.prototype.removeDuplicate = function()
{
// Here we remove duplicate values from first array
var array4 = new Array;
for(var i=0; i<this.length; i++)
{
var xx = true;
for(var j=i+1; j<this.length; j++)
{
if(this[i] == this[j])
xx = false;
}
if(xx == true)
array4.push(this[i]);
}
return array4;
}
Array.prototype.removeFrom = function(toberem)
{
// Here we remove duplicate values from first array
var array4 = new Array;
for(var i=0; i<this.length; i++)
{
var xx = true;
for(var j=0; j<toberem.length; j++)
{
if(this[i] == toberem[j])
xx = false;
}
if(xx == true)
array4.push(this[i]);
}
return array4;
}
</script>
<!-- Script by hscripts.com -->
Javascript Code
<!-- Script by hscripts.com -->
<!-- copyright of HIOX INDIA -->
<!-- Free javascripts @ http://www.hscripts.com -->
<script language=javascript>
function deldup()
{
var str1=document.strchk.val1.value;
var str2=document.strchk.val2.value;
var array1 = str1.split(',');
var array2 = str2.split(',');
array1 = array1.removeDuplicate();
alert(array1);
array2 = array2.removeDuplicate();
var aminusb = array1.removeFrom(array2); //(A-B)
var bminusa = array2.removeFrom(array1); //(B-A)
var aplusbs = array1.toString()+","+array2.toString();
var aplusb = aplusbs.split(",");
aplusb = aplusb.removeDuplicate(); //(A+B)
alert(aplusb);
}
</script>
<!-- Script by hscripts.com -->
Get free version without ©copyright link for just
5
|