473,508 Members | 2,390 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

duplicate values

18 New Member
Hello Everbody,

Please help me to catch the duplicate values. here is my script

function catchDuplicate()
{
with(document.form)
{

for (i=0; i < 26; i++)
Value = (document.getElementById("txtNoOfProcess" + i ).value = '' )

}
}


But I dont kow how I can pass the value to an array, so i can check if there's an duplicate value...
Mar 20 '07 #1
7 3625
acoder
16,027 Recognized Expert Moderator MVP
Create 2 new arrays.

Then as you are looping through the form values, use one array to store the non-duplicate values and the other to store the duplicate values.

To find out if a value is a duplicate, write a function which checks the non-duplicate array for the same value. If it's not present add it to that array, otherwise add it to the duplicate array (or, if you want to identify the form text box which contains the duplicate values, store the i value instead).

Read about arrays here.
Mar 20 '07 #2
intscript
18 New Member
Create 2 new arrays.

Then as you are looping through the form values, use one array to store the non-duplicate values and the other to store the duplicate values.

To find out if a value is a duplicate, write a function which checks the non-duplicate array for the same value. If it's not present add it to that array, otherwise add it to the duplicate array (or, if you want to identify the form text box which contains the duplicate values, store the i value instead).

Read about arrays here.
Here is my revised code, what is the error in this code? I can't pass the value to the arr[0]. I I can pass the value entered to the arr[0] the next time the user will input the value, it will check if there's a value stored in an array, so that alert message will prompt for the duplicate value. Thanks.

function check_Duplicate()
{
with(document.form)
{

var arr = new Array()

arr[0] = 0

for (i=0; i < hidNoOfProcess.value ; i++)

var propVals = document.getElementById("txtSeries" + i ).value

arr[0] = propVals


if( propVals == arr[0] ) {
alert("This is a duplicate value" +
"\n Please create another" );
return false;
}

}
}
Mar 21 '07 #3
mrhoo
428 Contributor
Expand|Select|Wrap|Line Numbers
  1. function check_Duplicate(){
  2. var arr = new Array(),count=0,L;
  3. for (i= 0; i < 26 ; i++){
  4.     var propVals = document.getElementById("txtSeries" + i ).value
  5.     L= arr.length;
  6.     count= 0;
  7.     while(count<L) if(arr[count++]===propVals){
  8.         alert(propvals+"  is a duplicate value"+
  9.         " \n Please create another" );
  10.  
  11.         return false;
  12.     }
  13.     arr.push(propVals)
  14. }
  15. return true;
  16. }
Mar 21 '07 #4
intscript
18 New Member
Expand|Select|Wrap|Line Numbers
  1. function check_Duplicate(){
  2. var arr = new Array(),count=0,L;
  3. for (i= 0; i < 26 ; i++){
  4.     var propVals = document.getElementById("txtSeries" + i ).value
  5.     L= arr.length;
  6.     count= 0;
  7.     while(count<L) if(arr[count++]===propVals){
  8.         alert(propvals+"  is a duplicate value"+
  9.         " \n Please create another" );
  10.  
  11.         return false;
  12.     }
  13.     arr.push(propVals)
  14. }
  15. return true;
  16. }
Thanks but I encountered error on first input of value it returns "is a duplicate value, second value is the same message , third value and so on and still prompting the error message however it still accepting duplicate values.

Thanks
Mar 21 '07 #5
intscript
18 New Member
Please help to store the value in a array

i have this code

function duplicate()
{
var arr = new Array()

for (i = 0; i < 26 ; i++)
{
// I want to pass this value to the array

Vals = document.getElementById("txtSeries" + i)

// if this value is already in the array, message error will prompt
alert('Value already exist')
break;

}


}
Mar 22 '07 #6
acoder
16,027 Recognized Expert Moderator MVP
Merged threads.
Mar 22 '07 #7
acoder
16,027 Recognized Expert Moderator MVP
Use
Expand|Select|Wrap|Line Numbers
  1. arr.push(Vals)
as suggested by mrhoo.
Mar 22 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

9
2984
by: NiQ | last post by:
Hello every one, this is about an array of string and may be have done several time before but i need it and wasnt able to find it so here is the problem i have an array of strings with contains...
2
1857
by: agekay | last post by:
Hi there, I would like to know how to get rows with duplicate values in certain columns. Let's say I have a table called "Songs" with the following columns: artist album title genre
3
5194
by: skennd | last post by:
Here's my problem in exact replication: I have used the find duplicate query in Access, and the query determined the following duplicate values by the following query: In (SELECT FROM As...
3
2169
by: munkis29 | last post by:
Hey all, Hopefully someone here can help me, I've got a problem and not sure how to aproach it. I'm using Access 2003 and have a table with one field: FileID in it there are many values, many of...
5
2447
by: kosta.triantafillou | last post by:
Hi all, I have a form that contains a lot of values. On this form there are also alot of popups that can be brought up. One of them does the following: Takes 2 values (x and y), concatenates...
10
28069
chandru8
by: chandru8 | last post by:
hi to all iam using vb6.0 can any one tell me how to duplicate values in a array if possible i want to delete the duplicate values its urgent thanks
2
1852
by: fabiola1 | last post by:
I'm using Ms Access 2003. I have five tables called tblAllContract tblType tbInteranlContact tblSupplier tblManager The other four tables are linked to tblAllContracts with Id's.I have a...
4
2866
by: ramdil | last post by:
Hi All I have table and it have around 90000 records.Its primary key is autonumber field and it has also have date column and name, then some other columns Now i have problem with the table,as my...
1
1318
by: ranjitha55 | last post by:
but it is displaying al values der in xml file.it should avoid reading duplicate values ,pls help me.. my code is, public class nm { public static void main(String argv) { try { File...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.