EasyCFM.COM ColdFusion Forums / Coding Help! / Best Practice Question...

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Best Practice Question...

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

][ce
07-22-2005 @ 1:29 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 25
Joined: Jul 2003

Hey everybody!

Quick question...
I have a form, that when it submits, if one of the fields equals 1 of 5 values, it performs an extra little piece of code.
I'm wondering which one would be better here:

<CFIF form.myField EQ "1" OR form.myField EQ "2" OR form.myField EQ "3" OR form.myField EQ "4" OR form.myField EQ "5">
<!--- Do extra stuff here... --->
</CFIF>


OR

<CFIF #find(form.myField, "1,2,3,4,5")#>
<!--- Do extra stuff here... --->
</CFIF>


... or maybe it's neither?

Any suggestions would be greatly appreciated!
Thanks,
Dave

JJfutbol
07-22-2005 @ 1:35 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1250
Joined: Nov 2004

Use ListFind(). I have read that it is considerably faster then the cfif statement above. In fact its perfect for yours as the example that I had read stating that ListFind was especially better to use is if you have a list (or var of several possible values) of 5 values or more. On my website I have a list of CF Best Practices and it will be the largest collection online. I will be adding more over the weekend as there  is not to much on it now. If you want me to add anything to it let me know!

----------------------------------------------------
Need FREE CF applications?? Then my site has it all, http://www.mygamingnation.com/coldfusion/downloads/ In time I will be including many more free CF apps as you will see many listed up top on that page.

This message was edited by JJfutbol on 7-22-05 @ 1:37 PM


Website Designed and Developed by Pablo Varando.