Connecting Tech Pros Worldwide Help | Site Map

Is name already exists in database don't save - how to?

Haitashi's Avatar
Member
 
Join Date: Jun 2007
Location: Orlando, FL
Posts: 94
#1: Nov 7 '08
I have collection object. Its recordset has the results of a query. And I have a form. Let's say that the form saves the user's first name. I want to be able to loop though that collection and compare the "firstName" value in the query to what the user has entered in the text input field. If it exists then don't submit the form.

I will add some nice message when a duplicate is found.

Not too sure how to go about this.

Can I do a compare?

Basically I want to:
>>Create collection object and populate it with query results
>>Loop through the recordset of said object and compare it to the value that inputted
>>If the string values are the same, then don't submit the form.

Thanks!
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Nov 7 '08

re: Is name already exists in database don't save - how to?


You can use a cfloop to loop over the collection. Then a comparison is as simple as using a cfif eq.
Haitashi's Avatar
Member
 
Join Date: Jun 2007
Location: Orlando, FL
Posts: 94
#3: Nov 10 '08

re: Is name already exists in database don't save - how to?


You were correct sir. That's what I did. =)
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Nov 10 '08

re: Is name already exists in database don't save - how to?


That's good to see and thanks for the confirmation :)
Reply