H I O X INDIA
FREE Javascript
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Directories 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)   Bookmarks :-)  
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

Java Script Source
List All
Date & Time
Calendar
Stop Watch script
Slide Show
Image Effect
Mouse Effects
Color Picker Tool
Dynamic Color
Random Generator
Select All
Form Validation
Textbox Counter
Dynamic Form select
Bookmark
Window / User Info
Security / Authenticate
Status Bar
Title Bar
Cursor Position
Country List
Calculators
Delete Repeated Values
Alphanumeric
Free Games





Remove duplicate values from one array using prototype function.


About
This free javascript can be used to remove duplicate values in single array using the javascript array prototype function. The array prototype function can be used anywhere to remove duplicates from an array.


Features
a)Give any repeated values with comma separated in the textarea
b)Just click the Remove Duplicates button
c)You can have sorted list of strings or numbers without repeated values


Preview
Deleting Duplicate values in single array:




Free Javascript Code
  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;
}
</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 del1array()
{                                                                                                                                                     
	var str1=document.txtchk.val1.value;
	var array1 = str1.split(',');
	array1 = array1.removeDuplicate();
	alert(array1);
}
</script>
<!-- Script by hscripts.com -->


Get free version without ©copyright link for just 5



Usage
a) Create a form with name "txtchk" and place a texarea with id val1

b)Create a button with name and call the function de11array()by using onclick txtchk.
Ex-
<form name="txtchk"> <textarea id="val1" rows="1" cols="20"></textarea>
<input value="Remove Duplicates" onclick="del1array()" type="button"> </form>


c)Now just copy the above free javascript code and prototype function in your web page inside the head tag.





License
- This javascript (misspelled as java script)/HTML code is given under GPL License
- i.e. Free use for those who use it as it is.
- Free, if your modification does not remove our copyright information and links.
- Detailed License information can be found here
- You can purchase the script if your requirements does not meet GPL License terms.


privacy policy     license     sitemap
© 2004-2005 HIOX INDIA - hioxindia.com

Others