You could build a dynamic query which only updates the fieldnames with
right(fieldname,4) eq 'date'
You can cfloop through form.fieldnames and if the index contains the string "date", do something with it.
Yes... but that is the part I need help with.
That's pretty vague.
I was wanting to use something like this:
<!--- this controls all date output --->
<cfparam name="#form.*Date# = dateModOutput">
<cfparam name="dateModOutput = DateFormat(form.*Date,"mmm/dd/yyyy")">
Your cfparam syntax seems strange to me. I would aim for something like <cfparam name="form.CTScanDate" default="#DateFormat(now(),'mmm/dd/yyyy')#">. Here, I have set form.CTScanDate by default to today's date.
The form.*Date would effect ALL DATEFIELD entries in the form
and so on...
Any code that would effectively do this is fine.
My boss said it can't be done... but I believe anything is possible and that this is probably very simple and easy.
Your boss is right. Partly. So are you. It can be done, however not by placing wildcards into form field names. I would follow the way Dan Bracuk pointed out, and do something like this:
<cfset formFieldNames = "CTScanDate,MRIScanDate,BoneScanDate">
<!--- Loop through list of field names --->
<cfloop list="#formFieldNames#" index="fieldName">
<!--- Pick out field names that end in 'date' --->
<cfif len(fieldName) GTE 4 and right(fieldName,4) is "date">
<cfparam name="form[fieldname]" default="#DateFormat(now(),'mmm/dd/yyyy')#">
I have assumed the form has not yet been submitted. Otherwise you wouldn't have to cfparam anything.
@ Dan Bracuk
Yes... you are correct. It is vague.
Mostly because I am a hack, and I have never written any of my own code.
I have only taken what I could find and edit it to make it work for my purposes.
I am totally guessing at what I think the code would look like and could work.
I was HOPING that someone like BKBK would come along... and tell me
that my approach is all wrong or re-write it for me so that it would work.
Which he did exactly that!
Thank you for your responses. I do appreciate your help!
This code is above my head!
But, you have done exactly what I was hoping someone would do.
Point out were my approach is wrong and point me in the RIGHT direction.
I will sit down with my Boss and hopefully
he can take this and run with it.
Thank you very much!
I will get back with you on how me make out!