A UDF may slightly lessen the code needed, and gain you some
flexibility, and readability too imo. Something like...

<cfscript>
function isFormComplete(ds, checkArray) {
  var result = true;
  for(i = 1; i LT arrayLen(checkArray); i = i + 1) {
    item = checkArray[i];
    //here is a case where compare() instead of EQ might make sense.
    if(NOT structKeyExists(ds, item) OR ds[item] EQ '') {
      var result = false;
      break;
    }
  }
  return result;
}
</cfscript>



<cfset checkList = "assetid, version, statusid, etc, etc">
<cfset checkArray = listToArray(checkList)>

<cfif isFormComplete(request.datastruct, checkArray)>
 <p><a href="writefile.cfm">Download Your XML File.</a></p>
</cfif>

I just typed this out so there is probably a problem with it, but if
you have any questions, shoot.

-- 
jon
mailto:[EMAIL PROTECTED]

Wednesday, August 21, 2002, 2:53:49 PM, you wrote:

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

DS> <!---Make sure everything required has been filled in.--->
DS> <cfif structkeyexists(request.datastruct, "assetid") AND
DS> request.datastruct.assetid is not ""
DS> AND
DS> structkeyexists(request.datastruct, "title") AND request.datastruct.title is
DS> not ""
DS> AND
DS> structkeyexists(request.datastruct, "description") AND
DS> request.datastruct.description is not "" AND
DS> structkeyexists(request.datastruct, "version") AND
DS> request.datastruct.version is not ""
DS> AND
DS> structkeyexists(request.datastruct, "statusid") AND
DS> request.datastruct.statusid is not ""
DS> AND
DS> structkeyexists(request.datastruct, "keywords") AND
DS> request.datastruct.keywords is not ""
DS> AND
DS> structkeyexists(request.datastruct, "formatid") AND
DS> request.datastruct.formatid is not ""
DS> AND
DS> structkeyexists(request.datastruct, "location") AND
DS> request.datastruct.locationid is not "">

DS> <!---Everything Required is Done--->

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

DS> </cfif>

______________________________________________________________________
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