13,001,686 members (89,508 online)
Rate this:
See more:
for example i have a string like 1,2,3,4,1,2 then i need to check each value with other values in for loop if any two values are same in string den i need to provide an alert can any help me for the logic ...advance thanks

example:first split-ed value is "1" it should check with 2,3,4,1,2 den at some point 1=1 then i should not provide an alert after completing total loop den i need to provide an alert
Posted 20-Feb-13 6:16am
Tharaka MTR 20-Feb-13 12:22pm

do you want to give the output once all the loop completed?
that's mean finally you want to give the alert saying "there are some duplicate value exists for 1 and 2?
Mounika Reddy 20-Feb-13 12:31pm

yes i have some id's string like 1,2,3,4,1,2 after selecting i will submit my record at the of submission i need to compare all id if any two id are same den i need to show an alert as "1 and 2 are already exists"

Rate this:

## Solution 1

Steps:
1. Split the string using ',' as a separator
2. create a flag 'isCopy' and set it to false
3. Start a loop for values one by one
4. if you find a match, then set the flag isCopy as true and continue the loop, don't do anything
5. Once the loop is complete, check for the value of flag
6. if flag value is true, show the alert or else move on to next item.

Try out now!
Sandeep Mewara 20-Feb-13 12:57pm

Then what will you do? Please don't say 'copy-paste'! :)

I provided the needed help and steps/algo. Try out.
Sergey Alexandrovich Kryukov 20-Feb-13 19:58pm

I would not agree with the vote of 3. I voted 5. The solution answers the question.
—SA
Sandeep Mewara 20-Feb-13 22:44pm

Thanks SA.

Top Experts
Last 24hrsThis month
 OriginalGriff 290 ppolymorphe 180 Bohdan Stupak 115 F-ES Sitecore 110 Dave Kreskowiak 60
 OriginalGriff 4,857 ppolymorphe 2,437 RickZeeland 2,221 Kornfeld Eliyahu Peter 2,031 Richard Deeming 1,643