473,320 Members | 2,054 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Removing duplicate values Javascript

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 them together with
an underscore in between and adds them to a select box in the same
popup (z). Then, when a user clicks a save button located on the
popup, it sends that information back to the main form and populates
the same three values (x, y, and z). What I need to do is make sure
that there are no duplicates in the x and y boxes on the main screen
before they proceed to the next step.

Any suggestions?

Thanks

Kosta

May 3 '07 #1
5 2440
I forgot to mention....when the values get sent back to the main form,
they are comma separated. Also, the original x and y values are
broken down (i.e. split on a comma, then split on the underscore to
retrieve the original values).

Thanks.
On May 3, 9:44 am, kosta.triantafil...@gmail.com wrote:
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 them together with
an underscore in between and adds them to a select box in the same
popup (z). Then, when a user clicks a save button located on the
popup, it sends that information back to the main form and populates
the same three values (x, y, and z). What I need to do is make sure
that there are no duplicates in the x and y boxes on the main screen
before they proceed to the next step.

Any suggestions?

Thanks

Kosta

May 3 '07 #2
Lee
ko*****************@gmail.com said:
>
I forgot to mention....when the values get sent back to the main form,
they are comma separated. Also, the original x and y values are
broken down (i.e. split on a comma, then split on the underscore to
retrieve the original values).

Thanks.
On May 3, 9:44 am, kosta.triantafil...@gmail.com wrote:
>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 them together with
an underscore in between and adds them to a select box in the same
popup (z). Then, when a user clicks a save button located on the
popup, it sends that information back to the main form and populates
the same three values (x, y, and z). What I need to do is make sure
that there are no duplicates in the x and y boxes on the main screen
before they proceed to the next step.
You're going to have to explain more clearly and precisely.
You haven't told us anything about your "x and y boxes", or
what it means to "proceed to the next step". I link to a
page would be helpful, or post the smallest example you can
contrive.
--

May 3 '07 #3
I can't really provide a link to this, as it is for a client and it is
confidential.

Basically, there are three metadata fields: H Number, PBP Number, and
Plan Code. The H Number and PBP Number combine together to form the
Plan Code (i.e. H Number = 111, PBP Number = 222, Plan Code =
111_222).

The main form will contain these three boxes:

Plan Code: __________ [button to click for popup window]
H Number:_________ [read only text box]
PBP Number: ________ [read only text box]

When someone clicks the button next to the Plan Code, it brings up a
pop window that contains a combo box for both the H Number and PBP
Number, and a select box for the Plan Code. A user will then enter an
H Number and PBP Number, and click an Add button located next to it.
This Add button calls a function that concats the H Number and PBP
Number together with an underscore in between. At the bottom of the
popup window is a Save button. Clicking this will send the Plan Code
information back to the main form. It will also split the Plan Code
value back into the original H and PBP Numbers and send that back to
the original form as well. Final result will look like this:

Plan Code: 111_222
H Number: 111
PBP Number: 222

What I need to do is ensure that there are no duplicate values for the
H and PBP Numbers on the main form. In other words, it CANNOT look
like this:

H Number: 111, 111
PBP Number: 222, 222

Any suggestions on how I can filter this out? Should I do it before I
hit the Save button?

Thanks alot,
Kosta

On May 3, 10:20 am, Lee <REM0VElbspamt...@cox.netwrote:
kosta.triantafil...@gmail.com said:


I forgot to mention....when the values get sent back to the main form,
they are comma separated. Also, the original x and y values are
broken down (i.e. split on a comma, then split on the underscore to
retrieve the original values).
Thanks.
On May 3, 9:44 am, kosta.triantafil...@gmail.com wrote:
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 them together with
an underscore in between and adds them to a select box in the same
popup (z). Then, when a user clicks a save button located on the
popup, it sends that information back to the main form and populates
the same three values (x, y, and z). What I need to do is make sure
that there are no duplicates in the x and y boxes on the main screen
before they proceed to the next step.

You're going to have to explain more clearly and precisely.
You haven't told us anything about your "x and y boxes", or
what it means to "proceed to the next step". I link to a
page would be helpful, or post the smallest example you can
contrive.

--- Hide quoted text -

- Show quoted text -

May 3 '07 #4
Lee
ko*****************@gmail.com said:
>
I can't really provide a link to this, as it is for a client and it is
confidential.

Basically, there are three metadata fields: H Number, PBP Number, and
Plan Code. The H Number and PBP Number combine together to form the
Plan Code (i.e. H Number = 111, PBP Number = 222, Plan Code =
111_222).

The main form will contain these three boxes:

Plan Code: __________ [button to click for popup window]
H Number:_________ [read only text box]
PBP Number: ________ [read only text box]

When someone clicks the button next to the Plan Code, it brings up a
pop window that contains a combo box for both the H Number and PBP
Number, and a select box for the Plan Code. A user will then enter an
H Number and PBP Number, and click an Add button located next to it.
This Add button calls a function that concats the H Number and PBP
Number together with an underscore in between. At the bottom of the
popup window is a Save button. Clicking this will send the Plan Code
information back to the main form. It will also split the Plan Code
value back into the original H and PBP Numbers and send that back to
the original form as well. Final result will look like this:

Plan Code: 111_222
H Number: 111
PBP Number: 222

What I need to do is ensure that there are no duplicate values for the
H and PBP Numbers on the main form. In other words, it CANNOT look
like this:

H Number: 111, 111
PBP Number: 222, 222

Any suggestions on how I can filter this out? Should I do it before I
hit the Save button?
I still don't know enough to give a detailed answer, but
at some point you need to maintain a list of values that
have already been added, and compare the new values to
each element in the list. Is it pairs of numbers (eg 111_222)
that you want to avoid duplicating, or individual numbers.
For example, could you have plan codes 111_222 and 111_333,
and, in that case, do you allow:
Plan Code: 111_222, 111_333
H Number: 111
PBP Number: 222, 333
--

May 4 '07 #5
kosta.triantafil...@gmail.com wrote:
[...]
What I need to do is ensure that there are no duplicate values
for the H and PBP Numbers on the main form. In other words,
it CANNOT look like this:
H Number: 111, 111
PBP Number: 222, 222
var P = ['11, 22', 'def, def', 'q,q', 'AG, Ag', '111, 111']
display(P)
var newP = new Array()
for (var i = 0; i<P.length; ++i) {
var spl = P[i].split(', ') // space after comma
if (spl[0] != spl[1])
newP.push(P[i]);
}
display(newP)

function display(arr) {
document.write('<hr>')
for (var j = 0; j<arr.length; ++j)
document.write(arr[j]+'<br>');
}

Hope this helps,

--
Bart

May 5 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Iain | last post by:
Hi I have inherited a web app with the following table structure, and need to produce a table without any duplicates. Email seems like the best unique identifier - so only one of each e-mail...
7
by: Utter Newbie | last post by:
Just wondeing if there is a way to keep from having a certain parameter sent when posting a form to another page (method=get)... So as an example a page will post something like this from a form...
9
by: vbportal | last post by:
Hi, I would like to add BitArrays to an ArrayList and then remove any duplicates - can someone please help me forward. I seem to have (at leaset ;-) )2 problems/lack of understanding (see test...
24
by: RyanTaylor | last post by:
I have a final coming up later this week in my beginning Java class and my prof has decided to give us possible Javascript code we may have to write. Problem is, we didn't really cover JS and what...
4
by: sri2097 | last post by:
Hi all, I'm storing number of dictionary values into a file using the 'cPickle' module and then am retrieving it. The following is the code for it - # Code for storing the values in the file...
1
by: gaikokujinkyofusho | last post by:
Hi, I have been enjoying being able to subscribe to RSS (http://kinja.com/user/thedigestibleaggie) for awhile and have come up with a fairly nice list of feeds but I have run into an annoying...
12
by: joestevens232 | last post by:
Hello Im having problems figuring out how to remove the duplicate entries in an array...Write a program that accepts a sequence of integers (some of which may repeat) as input into an array. Write...
1
by: PerumalSamy | last post by:
Hi I am having table with more 13 lakhs records. I am having duplicate records in it. i need to remove that. I wrote the following query SELECT *
3
by: rajeshkrsingh | last post by:
Hi friends, Step1- create table duplicate ( intId int, varName varchar(50) ) insert into duplicate(intId,varName) values(1,'rajesh') insert into duplicate(intId,varName) values(2,'raj12')...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.