> Hi Folks,
> I'm building an multi-part form, at the end of which, if someone has
> filled
> out all the required stuff, they can download an XML file generated from
> what they've filled in. I don't want to let them download the XML file
> until
> everything is complete, so right now I'm doing the following. But, it
> seems
> like there should be a better way, and I'm too tired today to think of it.
> Thoughts? (CF 5.0)

I would probably start by defaulting all those structure variables to empty
strings, i.e.

<cfset requiredfields =
"assetid,title,description,version,statusid,keywords,formatid,location">
<cfloop index="x" list="#requiredfields#">
        <cfparam name="request.datastruct.#x#"
                type="string" default="">
<cfloop>

Then you can just use len(trim(key)) to determine if a given key is filled
in... something like this might simplify it and make management easier:

<cftry>
        <cfloop index="x" list="#requiredfields#">
                <cfif not len(trim(request.datastruct[x]))>
                <cfthrow type="requiredfield" message="#x#"></cfif>
        </cfloop>

        <p><a href="writefile.cfm">Download Your XML File.</a></p>

        <cfcatch type="requiredfield"></cfcatch>
</cftry>



hth

Isaac Dealey
Certified Advanced ColdFusion 5 Developer

www.turnkey.to
954-776-0046
______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to