Hi, I NEED HELP,
In my application, we can add policy and attach its relevant document thru a form. the document is upload to a file on the server. besides the policy title, policy content, date created, department and author, the document name is stored in database as wpattachment (by using CFFILE.serverFile when INSERTing) and document size as wpAttachmentSize (by using CFFILE.fileSize). The policy info can be seen thru a list. if we click the policy name on the list, it goes to a form where we can view and edit the details of policy. When I do that, all the details except the attachment is shown. I want the attachment path to show in the text box besides the browse button in the View/Edit form. So please HELP. here is the code for
EditViewPolicy.cfm
============================================================
<cfinclude template="/Header.cfm">
<head>
<title>View/Edit Job</title>
<!---View Edit selected Policy--->
<CFQUERY name="Policy" Datasource="whitepaper">
SELECT *
FROM tblWhitePaper
WHERE wpID = #URL.wpID#
</CFQUERY>
<!---CF Query to get departments--->
<cfquery name="DeptList" datasource="whitepaper" dbtype="ODBC">
Select DeptID, Dept
From TblDepartment
Order BY Dept
</cfquery>
<!--Javscript for validating Policy content--->
<script language="javascript">
function validate(obj)
{
if(obj.wpcontent.value.length==0){
alert("Enter Policy Content!"
obj.wpcontent.focus();
return false;}
}
</script>
<!--Setting Submit as Default button-->
<script language="javascript">
function submitform() {
Attachment.submit()
}
</script>
</head>
<body>
<cfoutput>
<cfloop query="DeptList">
<cfif Dept is "#Session.Auth.Dept#">
<cfset DeptDefault="#DeptID#">
</cfif>
</cfloop>
</cfoutput>
<!---Cold Fusion Form Action: Submits to SubmitEditPolicy--->
<cfform action="SubmitEditPolicy.cfm" name="ViewEditPolicy"
method="POST" enctype="multipart/form-data"
OnSubmit="return validate(ViewEditPolicy);">
<table border="0" width="384">
<tr>
<th colspan="2">View /Edit Policy</th>
</tr>
<tr>
<td width="109">Title</td>
<td width="265">
<!--View and edit Existing Information-->
<cfoutput query="Policy">
<!--Pass wpID to SubmitEditPolicy.cfm for Editing-->
<input type="hidden" name="wpID" value="#wpID#">
<cfinput type="text" name="wpTitle" value="#wpTitle#"
MESSAGE="Title is required!" REQUIRED="Yes">
</td>
</tr>
<tr>
<td>Content</td>
<td>
<textarea name="wpcontent" rows="6" cols="60">
#wpcontent#</textarea>
</td>
</tr>
<tr>
<td>Date Created</td>
<td>
<cfinput type="text" name="wpDateCreated" value="#wpDateCreated#"
MESSAGE="Date Created is required!" Required="Yes"> i.e MM/DD/YYYY
</td>
</tr>
<tr>
<td>Department</td>
<td>
<cfselect name="wpdept" value="Deptid" display="Dept"
selected="#wpdept#" query="DeptList"
size="1" multiple="No"
Message="Department is required!" Required="yes">
</cfselect>
</td>
</tr>
<tr>
<td>Author</td>
<td>
<cfinput type="text" name="wpAuthor"
value="#session.Auth.LastName#, #session.auth.firstname#"
MESSAGE="Author is required!" Required="Yes">
</td>
</tr>
<tr>
<td>Attachment</td>
<td>
<input type="file" name="wpAttachment" size="40"
accept="application/msword,application/msexcel,application/pdf,text/html,application/rtf"
class="button2">
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="submit" value="Submit Form">
<input type="Button" name="Cancel" value="Cancel"
onClick="window.location='AdminPolicy.cfm';">
</td>
</tr>
</cfoutput>
</table>
</cfform>
</body>
<cfinclude template="/footer.cfm">
In my application, we can add policy and attach its relevant document thru a form. the document is upload to a file on the server. besides the policy title, policy content, date created, department and author, the document name is stored in database as wpattachment (by using CFFILE.serverFile when INSERTing) and document size as wpAttachmentSize (by using CFFILE.fileSize). The policy info can be seen thru a list. if we click the policy name on the list, it goes to a form where we can view and edit the details of policy. When I do that, all the details except the attachment is shown. I want the attachment path to show in the text box besides the browse button in the View/Edit form. So please HELP. here is the code for
EditViewPolicy.cfm
============================================================
<cfinclude template="/Header.cfm">
<head>
<title>View/Edit Job</title>
<!---View Edit selected Policy--->
<CFQUERY name="Policy" Datasource="whitepaper">
SELECT *
FROM tblWhitePaper
WHERE wpID = #URL.wpID#
</CFQUERY>
<!---CF Query to get departments--->
<cfquery name="DeptList" datasource="whitepaper" dbtype="ODBC">
Select DeptID, Dept
From TblDepartment
Order BY Dept
</cfquery>
<!--Javscript for validating Policy content--->
<script language="javascript">
function validate(obj)
{
if(obj.wpcontent.value.length==0){
alert("Enter Policy Content!"
obj.wpcontent.focus();
return false;}
}
</script>
<!--Setting Submit as Default button-->
<script language="javascript">
function submitform() {
Attachment.submit()
}
</script>
</head>
<body>
<cfoutput>
<cfloop query="DeptList">
<cfif Dept is "#Session.Auth.Dept#">
<cfset DeptDefault="#DeptID#">
</cfif>
</cfloop>
</cfoutput>
<!---Cold Fusion Form Action: Submits to SubmitEditPolicy--->
<cfform action="SubmitEditPolicy.cfm" name="ViewEditPolicy"
method="POST" enctype="multipart/form-data"
OnSubmit="return validate(ViewEditPolicy);">
<table border="0" width="384">
<tr>
<th colspan="2">View /Edit Policy</th>
</tr>
<tr>
<td width="109">Title</td>
<td width="265">
<!--View and edit Existing Information-->
<cfoutput query="Policy">
<!--Pass wpID to SubmitEditPolicy.cfm for Editing-->
<input type="hidden" name="wpID" value="#wpID#">
<cfinput type="text" name="wpTitle" value="#wpTitle#"
MESSAGE="Title is required!" REQUIRED="Yes">
</td>
</tr>
<tr>
<td>Content</td>
<td>
<textarea name="wpcontent" rows="6" cols="60">
#wpcontent#</textarea>
</td>
</tr>
<tr>
<td>Date Created</td>
<td>
<cfinput type="text" name="wpDateCreated" value="#wpDateCreated#"
MESSAGE="Date Created is required!" Required="Yes"> i.e MM/DD/YYYY
</td>
</tr>
<tr>
<td>Department</td>
<td>
<cfselect name="wpdept" value="Deptid" display="Dept"
selected="#wpdept#" query="DeptList"
size="1" multiple="No"
Message="Department is required!" Required="yes">
</cfselect>
</td>
</tr>
<tr>
<td>Author</td>
<td>
<cfinput type="text" name="wpAuthor"
value="#session.Auth.LastName#, #session.auth.firstname#"
MESSAGE="Author is required!" Required="Yes">
</td>
</tr>
<tr>
<td>Attachment</td>
<td>
<input type="file" name="wpAttachment" size="40"
accept="application/msword,application/msexcel,application/pdf,text/html,application/rtf"
class="button2">
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="submit" value="Submit Form">
<input type="Button" name="Cancel" value="Cancel"
onClick="window.location='AdminPolicy.cfm';">
</td>
</tr>
</cfoutput>
</table>
</cfform>
</body>
<cfinclude template="/footer.cfm">