Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

list find?

New Here ,
Jan 29, 2013 Jan 29, 2013

I have a form with mutiple text fields for user to enter email addresses.  I don't want them to enter the duplicate emails so created two lists here


Existing_EmailList: list all emails in the table.


Current_EmailList: all from the form (included from table and new email just enter)


I've tried to do ListContains, and Listfind but none of them work.  Can you help?

<cfset Existing_EmailList = valuelist(getCurrentEmail.email, ',') />
test@test.com, yes@yes.com, no@no.com

<cfset Current_EmailList = arguments.email />
test@test.com, yes@yes.com, no@no.com,no@no.com,one@one.com


<!---<cfif ListContains(Existing_EmailList, #Current_EmailList#)>--->
<cfif Listfind(Existing_EmailList, #Current_EmailList#)>
<cfset duplicate = true>
<cfelse>
<cfset duplicate = false>
</cfif>

Thanks

TOPICS
Getting started
530
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 29, 2013 Jan 29, 2013

I suggest a different approach altogether.  Query the database for the email submitted to see if it already exists.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 29, 2013 Jan 29, 2013
LATEST

How come the longer list is coming in as an argument? What is the point of one list completely including the other? Why not just find out whether the new e-mails are in the database as Dan suggests? It seems odd to be comparing two lists.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources