Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
February 3, 2008, 7:59 pm
rate this thread
I need to provide a function on my site whereby a user can enter a number of
ip addresses (one per line) so that I can submit this en masse to string
holding space in my db.
My problem is that I want to keep this list sorted as they enter the ip
addresses and I want to check for duplicates so that they don't enter the
same ip addresses twice.
I was going to do this as a simple form submit and add each entry as a
database row so that I could ORDER BY to get the sort and check for
duplicates on the submit, but this client/server submit really slows the
whole process. It would be great if I could order by and duplicate check on
the client side so that once done all I'm doing is one client/server 'post'
to the db.
Is this feasible?
Wow, why didn't you post in even *more* groups?
The former is extremely annoying in my experience. I expect something I've
added to appear on the bottom of a list. If you keep a list sorted, people
might have to scan the whole list to see where it went.
As checking for duplicates, that should be a piece of cake in any
language, no need to keep it sorted. The keyword is a hash table (aka
associative array), I am sure JS does support something like that out of
the box. But read on...
Assuming MySQL, you can safely insert duplicates by overwriting them with
ON DUPLICATE SET ...
If you put on top of your form: duplicates will be ignored, the user knows
what happens when he/she sees he's entered a duplicate. If he/she has
entered a duplicate it's already too late. I mean, you can remove it while
the line is entered, but the question is (to me): should you. And I would
say: no. (Also, without any warning the user wonders where the line went
she/he just entered).
John Bokma http://johnbokma.com/
As a slight refinement, I expect it to be added to the list closest to
the input. I recently put a dynamic list on a site that has the entry
field at the top, and while I started by adding new items to the bottom,
it seemed to flow better when they're added to the top and the list
A possible solution is to do a live scan of the list as the user enters
characters and highlight matches. That allows both feedback for
duplicates (nobody should be surprised if they can't be entered again)
and doubles as a search utility.
My personal UDP list: 127.0.0.1, 4ax.com, buzzardnews.com, googlegroups.com,
heapnode.com, localhost, ntli.net, teranews.com, vif.com, x-privat.org