Hey Everyone,
well was hoping if someone could explain to me how to add an alert for the description fields of this multiple attachments script. The problem i think i am having is i don't know how to make it check multiple fields to make sure each field has been checked for a description before submitting. Here is what i have
on my form page
where it goes after i click submit
i tried this but clearly i am missing a lot
Thank you in advance,
Rach
well was hoping if someone could explain to me how to add an alert for the description fields of this multiple attachments script. The problem i think i am having is i don't know how to make it check multiple fields to make sure each field has been checked for a description before submitting. Here is what i have
on my form page
Code:
<input type="file" name="attachment1" id="attachments" value="1" onchange="document.getElementById('moreUploadsLink').style.display = 'block';" />
Description <input type="text" name="description1" id="description" value="" />
<div id="moreUploads"></div>
<div id="moreUploadsLink" style="display:none;">
<input type="button" value="Attach another file"
onclick="javascript:addFileInput();" >
</div>
<input type="hidden" name="uploads" id="uploads" value="1">
Code:
<!---Inserts attachments into attachments.--->
<cfif structKeyExists(FORM, "uploads")>
<cfset currentDirectory = GetDirectoryFromPath(GetTemplatePath()) & "uploaded">
<cfparam name="FORM.uploads" default="">
<cfloop list="#form.uploads#" index="counter">
<cfset currentDescription = form["description" & counter]>
<!--- verify the form field exists --->
<cfif structKeyExists(FORM, "attachment"& counter)>
<!--- try and upload it ...--->
<cftry>
<cfif Len(FORM["attachment#counter#"])>
<cffile action="upload" fileField="form.attachment#counter#" destination="C:\Inetpub\Development\WWWRoot\RachelB\footprints\form\attachments\" nameconflict="MAKEUNIQUE">
<cfset filename = cffile.ClientFileName & "_" & form.id & "_" & counter & "." & cffile.ClientFileExt>
<!--- IF RUN INTO PROBLEMS WITH FILES NOT GOING INTO TABLE MAKE SURE EVERYTHING BETWEEN SOURCE="" IS ALL ON ONE LINE--->
<CFFILE ACTION="RENAME" SOURCE="C:\Inetpub\Development\WWWRoot\RachelB\footprints\form\attachments\#CFFILE.ServerFile#" destination="C:\Inetpub\Development\WWWRoot\RachelB\footprints\ form\attachments\#filename#">
<cfquery name="attachment" datasource="CustomerSupport">
exec usp_CS_Insertattachments
'#Form.ID#','#evaluate(serialnum)#','#currentDescription#','#filename#','#Form.fk_addedBy#'
</cfquery>
</cfif>
<cfcatch><!--- do something here, e.g. display error message.. --->
</cfcatch>
</cftry>
</cfif>
</cfloop>
</cfif>
Code:
if(description1.value== "")
{
alert ("Please fill in the description for your attachment");
return false;
}
Rach
Comment