JavaScript Scripts





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Free Java Script Codes
Javascript List All
Slide Show Slide Show
Ad Display Ad Display
Image Effect Image Effect
Animated Image Effects Animated Image Effects
Form Validation Form Validation
Color Picker Tool Color Picker Tool
Formatting Forms Formatting Forms
Select All Select All
Dynamic Form Select Dynamic Form select
Dynamic Color Dynamic Color
Calendar Script Calendar
Textbox Counter Textbox Counter
Alphanumeric Alphanumeric
Date Time Script Date & Time
Stop Watch Script Stop Watch script
Delete Repeated Values Delete Repeated Values
Pagination Pagination
Random Generator Random Generator
Animated Text Animated Text
Cursor Position Cursor Position
User Info Window / User Info
Security Security / Authenticate
Bookmark Bookmark
Mouse Effects Mouse Effects
Title Bar Title Bar
Status Bar Status Bar
Country List Country List
Free Games Free Games
Calculators Calculators
 




Remove duplicate from two arrays using the prototype function.


About
This free javascript can be used to concatenate two array values after removing the duplicates.


Features
a)Give any repeated values in both the textareas with comma(,) seperated.
b)Just click the Remove Duplicates button.
c)This function shows concatenated list of strings or numbers without repeated values.

Preview
Remove duplicates and concatenate two arrays:




Free Javascript Code
  Prototype Function
<!--        Script by hscripts.com          -->
<!--        copyright of HIOX INDIA         -->
<!-- Free javascripts @ http://www.hscripts.com -->
<script type="text/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 type="text/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 price

For customization of this script or any script development, contact us at support@hscripts.com


Usage
a) Create a form with name "strchk" and place two textareas with id's val1 and val2
Ex:-
<form name ="txtchk">
<textarea id="val1" rows="1" cols="20"></textarea>
<textarea id="val2" rows="1" cols="20"></textarea>
</form>
b) Create a button with name and call the function deldup()by using onclick event.
Ex-
<input type="button" value="Remove Duplicates" onclick="deldup()" >
c) Now just copy the free javascript and prototype functions within the head tag
d) Alert the result with concatenated strings without any duplicate values or display in new textarea



License
- The javascript (misspelled as java script) is given under GPL License
- i.e. Free use for those who use the codes as it is.
- Free, if your modification does not remove our copyright information and links.
- Click Here for detailed license information.
- You can purchase the script if your requirements does not meet our GPL License terms.
Other Links

web hosting