Solved

How to update a record using a checkbox, in a column with datatype bit, setting value to True or False?

Posted on 2010-08-19
59
588 Views
Last Modified: 2012-05-10
ColdFusion 8
MS SQL Server 2005

I've been at this task for about eight hours and have reached a point at which it's more efficient to ask for help. Probably should have asked four hours ago but wanted to try every possible idea I could.

gdemaria, _agx_, and azadi, and Plucka have worked with me on this task previously. It is the CEP Insert / Update form. The client has asked me to change the form to include an option to mark a particular file as a Press Release using a checkbox.

When the isPressRelease checkbox is checked, then the file is considered a press release. When unchecked, then the file is not considered a press release.

Notes and question:

* I have an Update form that updates a record in table tbl_CEP_Files.

* A checkbox form field with name isPressPelease  updates column isPressPelease  in table tbl_CEP_Files.

* Column isPressPelease has datatype bit.

* If you select (check) checkbox isPressPelease  and process the form, then column isPressPelease  in table tbl_CEP_Files is changed to True -- this works as expected.

* Only the correct record in table tbl_CEP_Files is changed to True -- also working as expected.

* However, if I uncheck the checkbox isPressPelease  and process the form, then -- nothing happens. The record is still set to isPressPelease = True in the database.

How can I get this form to update column isPressPelease  to False for the selected record?

* Please note that, in this application, "documents" are different from "files". A document is a CEP publication, which can contain or encompass several "files" such as a Full Report PDF, a Press Release PDF, or an Appendix PDF.

I attach several things below. The full application is there at the end, in case you need to see it. But I highlight the pertinent sections here:

1. Here is the query that requests all columns from tbl_CEP_files (line 569)

   <!--- query to get columns and values from tbl_CEP_files, for use below --->
<cfquery name="getFiles" datasource="#ds#">
    SELECT *
    FROM tbl_CEP_files
    WHERE DocumentID=<cfqueryparam value="#val(form.DocumentID)#" cfsqltype="cf_sql_integer"> 
    AND isDeleted = 0
  </cfquery>

Open in new window


2. The isPressRelease checkbox (line 633)

 <cfinput type="checkbox" name="isPressReleaseID" value="#getFiles.fileID#" checked="#isPressRelease eq 1#"  />

Open in new window



3. The query that updates tbl_CEP_Files (line 265)

       <!--- SET OR UNSET A FILE TO isPressRelease --->
      <!--- this query must be placed within the Save Action --->
 
    	   <!--- begin CFELSEIF isDefined(form.isPressReleaseID) --->
		 <cfelseif isDefined("form.isPressReleaseID")>
   
	<!---- query to set table tbl_CEP_Files, column isPressRelease to 1 or 0 ---->
    	   <cfquery name="qry_updateisPressRelease" datasource="#ds#">
       			UPDATE tbl_CEP_Files
           		SET isPressRelease = <cfqueryparam cfsqltype="cf_sql_bit" value="#Trim(form.isPressReleaseID)#">
        		WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#form.isPressReleaseID#" list="yes">)
      		</cfquery> 
      

Open in new window

     


Also, a note: I set some default values for form.isPressRelease:
<!--- set default values for form check boxes --->
<cfif isDefined('form.isPressRelease')>
<!--- checkbox has been checked and is present in post data --->
<cfset form.isPressRelease = 1>
<cfelse>
<cfset form.isPressRelease = 0>
<!--- checkbox not checked and not present --->
</cfif>

Open in new window


Thank you for any advice about this.

Eric B
<!---

Name:        insert_update.cfm

Author:      Eric B, following Ben Forta code in ColdFusion 8 web application construction kit; gdemaria; azadi; _agx_; Plucka; myselfrandhawa

Description: CEP add and update documents administration

Created:     2/24/2010 - 6/22/2010

ColdFusion Version 8

MS SQL Server 2005

--->





 <!--- Set default value for FileID in scope FORM --->

<cfparam name="form.FileID" default="">



 <!--- Set default value for NumberFiles in scope FORM --->

<cfparam name="form.NumberFiles" default="">



 <!--- Set default value for SelectDocumentTopics in scope FORM --->

<cfparam name="form.SelectDocumentTopics" default="0" />







 <!--- Set default value for DocumentID in scope URL --->

<cfparam name="URL.DocumentID" default="">



 <!--- Define DocumentID in scope FORM, then set form.DocumentID equal to the DocumentID passed in the URL: for use later in the application --->

<cfparam name="form.DocumentID" default="#URL.DocumentID#">









<!--- set default values for form check boxes --->

<cfif isDefined('form.isPressRelease')>

<!--- checkbox has been checked and is present in post data --->

<cfset form.isPressRelease = 1>

<cfelse>

<cfset form.isPressRelease = 0>

<!--- checkbox not checked and not present --->

</cfif>







 <!--- Set datasource --->

 <cfset ds="ebwebwork">

  

 <!---- begin CFTRY; catch any errors, whether you throw them or the database does; and to test that file were uploaded successfully, or not  ---->

 <cftry>  

 



<!---- populate this with an error message ---->

<cfset variables.error = ""> 





        <!--- BEGIN: Save action --->





<!--- begin form.doSave --->



<!--- when the user clicks the Save Button, these events can occur: Add a document; Update a document; Delete a Document; Delete a file that is associated with a document --->



<cfif IsDefined("FORM.doSave")>





<!--- make sure that documentTitle and documentType are entered --->  

    

	<cfif len(form.DocumentTitle) eq 0>

			  <cfthrow message="Document Title is required">

	</cfif>

    

    <cfif len(form.DocumentType) eq 0>

			  <cfthrow message="Document Type is required">

	</cfif>





 <!--- in this query select NOTHING from table tbl_CEP_documents, and simply check if DocumentTitle exists --->

 

 <cfquery datasource="#ds#" name="CheckDocumentTitle">

  SELECT 'Nothing' FROM tbl_CEP_Documents

  WHERE DocumentTitle = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Form.DocumentTitle#">

  AND DocumentID <> <cfqueryparam cfsqltype="cf_sql_integer" value="#val(Form.DocumentID)#">

  </cfquery>

   

 

  

   <!--- if DocumentTitle exists, display error; refuse record insert --->

   

	<cfif CheckDocumentTitle.recordcount GT 0>

		   <cfthrow message="The Document Title is already taken; please enter another title">

	</cfif>

    

    <!--- begin statements to update, insert database records --->  

   

    <!--- begin cfif val(form.DocumentID) --->

    

    <!--- the action is UPDATE; a DocumentID Exists --->

    

				<cfif val(form.DocumentID)>

                

         

                

<!--- group three queries in a cftransaction: UPDATE Document; DELETE Document Topics; INSERT (new) Document Topics--->

<cftransaction>

    

  			  <cfquery name="UpdateDocument" datasource="#ds#">

				  UPDATE tbl_CEP_Documents

				  SET   DocumentTitle = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentTitle)#">,

					DocumentType = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentType)#">,

					DocumentAuthor = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentAuthor)#">,

				    DocumentAbstract = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentAbstract)#">,

				    DocumentPublicationDate = <cfqueryparam cfsqltype="cf_sql_date" value="#Trim(form.DocumentPublicationDate)#">,

				    DateRecordModified = <cfqueryparam cfsqltype="cf_sql_timestamp" value="#now()#">

				  WHERE DocumentID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.DocumentID)#">

			</cfquery>





<cfquery name="UpdateDocumentDeleteTopics" datasource="#ds#">

   DELETE FROM tbl_Document_Has_Topic

   WHERE DocumentID = <cfqueryparam value="#form.DocumentID#" cfsqltype="cf_sql_integer">

</cfquery>



<cfquery name="UpdateDocumentInsertNewTopics" datasource="#ds#">

INSERT INTO tbl_Document_Has_Topic

		(

        DocumentID

        ,  DocumentTopicID

        )

SELECT   <cfqueryparam value="#form.DocumentID#" cfsqltype="cf_sql_integer">

         , DocumentTopicID

FROM     tbl_CEP_Document_Topic

WHERE   DocumentTopicID  IN

(

<cfqueryparam value="#form.SelectDocumentTopics#" cfsqltype="cf_sql_integer" list="true">

)

</cfquery>

</cftransaction>







    <!--- CFELSE: DocumentID does not exist, then insert new document --->

				<cfelse> 

                

                

      <!--- use two queries: one to insert the record into tbl_CEP_Documents; one to insert DocumentID and DocumentTopicID into tbl_Document_Has_Topic  --->

      <!--- use cftransaction so both queries are processed together  --->

    

    

        <cftransaction>

	

				<!---- query to insert new document record into tbl_CEP_Documents ---->

					<cfquery name="InsertDocument" datasource="#ds#" result="newDocument">

				 INSERT INTO tbl_CEP_Documents

     					(

			            DocumentTitle,

            		    DocumentType,

                		DocumentAuthor,

		                DocumentAbstract,

        		        DocumentPublicationDate,

                		SSMA_TimeStamp

		                )

			     valueS(

						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentTitle)#">,

						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentType)#">,

						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentAuthor)#">,

						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentAbstract)#">,

						  <cfqueryparam cfsqltype="cf_sql_date" value="#Trim(form.DocumentPublicationDate)#">,

		     			  <cfqueryparam cfsqltype="cf_sql_timestamp" value="#now()#">

				         )         

					</cfquery>

                  

    <!--- cfquery to get the selected document topics, and insert them into tbl_Document_Has_Topic along with the document ID --->

            <cfquery name="InsertDocumentTopics" datasource="#ds#">

                 INSERT INTO tbl_Document_Has_Topic

                 		(

                        DocumentID,

                        DocumentTopicID

                        )

                  SELECT

                   <cfqueryparam value="#newDocument.IDENTITYCOL#" cfsqltype="cf_sql_integer">

                   , DocumentTopicID

                   FROM  tbl_CEP_Document_Topic

                   WHERE   DocumentTopicID  IN

                  (

                     <cfqueryparam value="#form.SelectDocumentTopics#" cfsqltype="cf_sql_integer" list="true">

                  )

               </cfquery>

        </cftransaction>     

             

                  

                    

	 <!--- use the result attribute value to set the form field value --->

      <cfset form.DocumentID = newDocument.IDENTITYCOL>



		<!--- END queries to update or insert database records ---> 



        <!--- END cfif val(form.DocumentID) -- if a document needed to be updated, or added, then it was done --->

					    </cfif>  

    

    

    

	   <!--- ============= BEGIN query to update column FileLinkText in tbl_CEP_Files ============= --->   

              <!--- this section must be placed within the Save Action --->  

 

        <cfloop index="kk" from="1" to="#val(form.numberFiles)#"> 

            <cfset form.updateFileLinkText = form['updateFileLinkText' & kk]>

            <cfset form.fileID = form['fileID' & kk]>

        

             <cfquery name="query_updateFileLinkText" datasource="#ds#">

                UPDATE tbl_CEP_Files

                SET FileLinkText = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.updateFileLinkText)#">

                WHERE FileID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.fileID)#">

             </cfquery>            

         

        </cfloop>

     

        <!--- ============= END query to update column FileLinkText in tbl_CEP_Files ============= --->   

    



    

<!--- remember cfif IsDefined("FORM.doSave") is still defined -- remember to close the cfif later --->

    

  

				<!--- test to see whether or not a file is being uploaded -- does form field FileName contain a file? --->         

  

		    	<!--- BEGIN: if form field FileName contains a file, then upload the file and the file's metadata --- this function updates the tbl_CEP_Files--->

      		<cfif form.fileName is not "">

     

              

			    <!--- BEGIN: upload a file using CFFILE --->       

     			<!--- cffile upload --->       

   			      <cffile action="upload" filefield="FileName" destination="c:\upload\cep-dc.org" nameconflict="overwrite">



			<cfif listFindNoCase("doc,docx,jpg,jpeg,png,gif,pdf,ppt,xls,xlsx,txt", cffile.serverFileExt) eq 0>

				    <cfthrow message="Your file did not upload. You may upload only permitted file types.">

			</cfif>

            



			<!---- query to insert new record into tbl_CEP_Files, with a file  (DOC, JPEG, PDF, etc.) to upload ---->

			<cfquery name="InsertFile" datasource="#ds#">

			 INSERT INTO tbl_CEP_Files

     			(

                DocumentID,

                FileName,

                FileLinkText,

				FileExtension,

				FileType,

				FileSize,

                isDeleted,

                isPressRelease

                )

		     valueS(

        		  <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.DocumentID)#">

				  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#cffile.clientFile#">

                  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.FileLinkText)#">

				  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#cffile.clientFileExt#">

				  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#cffile.contentType#">

				  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#cffile.fileSize#">

                  ,0

                  ,0

		           )         

				</cfquery>  

  

		   <!--- END query to insert new record into tbl_CEP_Files --->  

 

 



              <!--- SET OR UNSET A FILE TO isPressRelease --->

      <!--- this query must be placed within the Save Action --->

 

    	   <!--- begin CFELSEIF isDefined(form.isPressReleaseID) --->

		 <cfelseif isDefined("form.isPressReleaseID")>

   

	<!---- query to set table tbl_CEP_Files, column isPressRelease to 1 or 0 ---->

    	   <cfquery name="qry_updateisPressRelease" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET isPressRelease = <cfqueryparam cfsqltype="cf_sql_bit" value="#Trim(form.isPressReleaseID)#">

        		WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#form.isPressReleaseID#" list="yes">)

      		</cfquery>

  

  

           

              <!--- DELETE A FILE --->

      <!--- this query must be placed within the Save Action --->

 

    

    	   <!--- begin CFELSEIF isdefined(form.deleteFileID) --->

		 <cfelseif isDefined("form.deleteFileID")>        

   

	<!---- query to set a file to isDeleted = 1 ---->

    	   <cfquery name="qry_deleteFile" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET IsDeleted = 1

        		WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#form.deleteFileID#" list="yes">)

      		</cfquery>





            </cfif>

<!----- END form.fileName is not "" test to see if file is being uploaded ---->







	<!--- if insert record succeeded, and / or file upload succeeded, and / or FileLinkText were updated, then go to index page --->

				     <cflocation url="index.cfm" addtoken="no">



        

                    

    <!--- END: Save action --->

    



  

        <!--- BEGIN: Delete action --->





			   <!--- delete a database record --->

					   <!--- begin CFELSEIF isdefined(form.doDelete) --->

					        <cfelseif isDefined("form.doDelete")>        

					        <!---- query to delete record ---->

                            

                            <cftransaction>

					       	<cfquery name="DeleteDocument" datasource="#ds#">

					         DELETE FROM tbl_CEP_Documents

					         WHERE DocumentID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.DocumentID)#">

					        </cfquery>

                                                        

                            <cfquery name="UpdateDocumentDeleteTopics" datasource="#ds#">

							   DELETE FROM tbl_Document_Has_Topic

							   WHERE DocumentID = <cfqueryparam value="#form.DocumentID#" cfsqltype="cf_sql_integer">

							</cfquery>

                            </cftransaction>

              

 					        <!---- after delete, go to index page ---->

						 <cflocation url="index.cfm" addtoken="no">



	    <!--- END: Delete action --->

        

  



  <!--- END form.doSave --->

</cfif>











       <!--- this CFCATCH will trap errors -- the ones you threw or just regular database issues --->

<cfcatch type="Any">

     <cfset variables.error = cfcatch.message>

     <cfrethrow>

  </cfcatch>



  

  

  

		  <!--- END CFTRY --->  

			</cftry>







<!--- fetch the data from the database only when there are no errors.

      if an error exists, then let the form variables pass back into the form to display ---->

 

  <cfif len(variables.error) eq 0>

    

			  <!--- get data from table tbl_CEP_Documents and convert the data into form variables --->

			  <cfquery name="getDocumentDetails" datasource="#ds#">

				    select * from tbl_CEP_Documents where DocumentID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.DocumentID)#">

			  </cfquery>



  			<cfloop index="aCol" list="#getDocumentDetails.columnList#">

			       <cfset "form.#aCol#" = getDocumentDetails[aCol][getDocumentDetails.currentRow]>

			  </cfloop>

    

	</cfif>











<!--- BEGIN HTML / CSS PAGE HEADER --->

<cfinclude template="/cep/cep_header_admin.cfm" />









<!--- if there an error, display error in human readable form --->



<cfif len(variables.error)> 

			 <cfoutput>

			 <div style="border: 1px solid red; padding: 10px; margin:20px; width:400px;">#variables.error#</div>

			 </cfoutput>

</cfif>















				<!----- if record already exists (it will have an ID) then update it; otherwise, add new record... ----->

				<cfif val(form.documentID)>

					  <cfset FormTitle="Edit Document">

					  <cfset ButtonText="Update This Document">

  					  <cfset FileLinkTextButton="Update File Link Text">

				<cfelse>

						<cfset FormTitle="Add a Document">

						<cfset ButtonText="Add Document">



				</cfif>



  

				<!--- Add or Update Document Form begins here --->

				<cfform method="post" enctype="multipart/form-data" scriptsrc="#Request.CFFORM_JS_LIB#">





 <!--- Embed documentID (PK), fileID, numberFiles as hidden fields, to assign a value to each --->

 <cfoutput>

<input type="hidden" name="documentID" value="#form.documentID#" />



   </cfoutput>







  <cfoutput>



      <h2>#FormTitle#</h2>



  </cfoutput>

  

  

  <!--- BEGIN TABLE ADMIN; DISPLAY DOCUMENT DETAILS --->

 

<table class="table_admin">

<cfif val(form.documentID)>

 <tr>

  <td>

<p><strong>Document ID: <cfoutput>#URL.DocumentID#</cfoutput></strong></p>

  </td>

 </tr>

 <cfelse>

 </cfif>



 <tr>

  <td>

   <p><strong>Document Title</strong><br />



   <cfinput type="Text"

            name="DocumentTitle"

            value="#form.DocumentTitle#"

            message="Document title is required! Please restrict the Document title to 100 characters or fewer."

            required="Yes"

            validateAt="onSubmit,onServer"

            size="100"

            maxlength="250" /></p>

  </td>

 </tr>

 <tr>

  <td>

   <p><strong>Document Type</strong>  <a href="#" class="hintanchor" onMouseover="showhint('Don\'t worry too much about document type. Specify document type \'Report\' for most CEP documents.', this, event, '200px')">[?]</a></p>



   <select name="DocumentType" value="#form.DocumentType#">

   			<option value="Report">Report</option>

            <option value="Policy Brief">Policy Brief</option>

            <option value="Press Release">Press Release</option>

            <option value="Article">Article</option>

            <option value="Summary">Summary</option>

            <option value="Letter">Letter</option>

            <option value="Audio Transcript">Audio Transcript</option>

            <option value="Text Transcript">Text Transcript</option>

   </select>

  </td>

 </tr>





 <tr>

  <td>

   <p><strong>Document Author</strong><br />



   <cfinput type="Text"

            name="DocumentAuthor"

            value="#form.DocumentAuthor#"

            message="Enter Document Author Name"

            required="yes"

            validateAt="onSubmit,onServer"

            size="100"

            maxlength="100" /></p>

  </td>

 </tr>

 

 

<!--- this query requests values from columns DocumentTopicID and DocumentTopic in tbl_CEP_Document_Topics --->

 <cfquery datasource="#ds#" name="GetDocumentTopics">

SELECT DocumentTopicID, DocumentTopic

FROM tbl_CEP_Document_Topic

ORDER BY DocumentTopic

  </cfquery>

 

  <tr>

  <td>

    <p><strong>Assign this Document to CEP Topics</strong> <a href="#" class="hintanchor" onMouseover="showhint('Assign this document to a topic', this, event, '200px')">[?]</a></p>

    

    

      <p class="small">Choose at least one topic. To select more than one topic, hold the Ctrl or the Shift key (on your keyboard) and select topics with the mouse cursor.</p>

   



<!--- query to get existing topics for the current documentID --->



       <cfquery datasource="#ds#" name="GetSelectedTopics">

              SELECT DocumentTopicID

              FROM    tbl_Document_Has_Topic

              WHERE  DocumentID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.documentID)#">

       </cfquery>

     

       <!--- convert the DocumentTopicID values to a list --->

      <cfset form.SelectDocumentTopics = ValueList(GetSelectedTopics.DocumentTopicID)>



<cfselect name="SelectDocumentTopics"

size="8"

multiple="yes"

query="GetDocumentTopics"

queryPosition="below"

value="DocumentTopicID"

display="DocumentTopic"

selected="#form.SelectDocumentTopics#">

     <option value="0">Choose topic:</option>

</cfselect>

 

  </td>

 </tr>

 



 <tr>

  <td>

   <p><strong>Document Abstract</strong><br />

   <cfoutput>

   <textarea name="DocumentAbstract" wrap="virtual" style ="width:600px; height:250px;">#form.DocumentAbstract#</textarea>

   </cfoutput></p>

  </td>

 </tr>

 

 

 <tr>

  <td>

   <p><strong>Publication Date (use form MM/DD/YYYY; please click the calendar icon, below)</strong><br />

   <cfinput name="DocumentPublicationDate"

            value="#DateFormat(DocumentPublicationDate, "mm/dd/yyyy")#"

            message="Publication Date must be a valid date!"

            required="no"

            validate="usdate"

            validateAt="onSubmit,onServer"

            size="10"

            maxlength="10"

            type="datefield" mask="MM/DD/YYYY" /></p>

  </td>

 </tr>

 </table>



  <!--- END TABLE ADMIN; DISPLAY DOCUMENT DETAILS --->

  







   <!--- display the files currently associated with the document --->



<cfif val(form.documentID)>

<p>Below, please see the files currently associated with Document ID <strong><cfoutput>#URL.DocumentID#</cfoutput></strong>. If there are no files associated with the document, then no files will appear below. You have the option to upload a file (PDF, DOC, image file), which will associate the file with this document.</p>

<cfelse>

<p>This is a new document. You have the option to upload a file (PDF, DOC, image file), which will associate the file with this document.</p>

</cfif>





   <!--- query to get columns and values from tbl_CEP_files, for use below --->

<cfquery name="getFiles" datasource="#ds#">

    SELECT *

    FROM tbl_CEP_files

    WHERE DocumentID=<cfqueryparam value="#val(form.DocumentID)#" cfsqltype="cf_sql_integer"> 

    AND isDeleted = 0

  </cfquery>

  



  <cfif getFiles.recordCount>

   <table class="tablecontrolpanel width600px">

     <tr>

      <td><strong>File ID</strong></td>

      <td><strong>Files associated with this CEP document:</strong></td>

      <td><strong>File Link Text</strong> <a href="#" class="hintanchor" onMouseover="showhint('What link text should the user click on to open this file?', this, event, '200px')">[?]</a></td>

      <td><strong>Mark for Deletion</strong>  <a href="#" class="hintanchor" onMouseover="showhint('If you want this file to no longer associate with this document, you can mark the file for deletion; the file will be deleted from the server', this, event, '200px')">[?]</a></td>

      <td><strong>Press Release</strong>  <a href="#" class="hintanchor" onMouseover="showhint('Mark this file as a Press Release', this, event, '200px')">[?]</a></td>

      

     </tr>

     

     

    <!--- loop through files called by query getFiles ---> 

     <cfloop query="getFiles">

     

     

	  

	 <cfoutput>

     <input type="hidden" name="numberFiles" value="#getFiles.recordCount#">

          

     <cfif CurrentRow MOD 2 IS 1>

        <cfset bgcolor="##ffffff">

        <cfelse>

        <cfset bgcolor="##ebebeb">

      </cfif>

      

     <tr style="background-color:#bgcolor#">



        <!---  get list of file IDs --->  

       <td>#getFiles.FileID#</td>







        <!---  get list of file names --->  

       <td>#getFiles.FileName#</td>

       



        <!--- input field to update file link text --->   

        

        <cfset CTR = getFiles.currentRow>

          

       <td><cfinput type="Text"

            name="updateFileLinkText#CTR#"

            value="#getFiles.FileLinkText#"

            size="50"

            maxlength="100" />

            <input type="hidden" name="fileID#CTR#" value="#getFiles.fileID#" />

       </td>

               

      

         <!--- Mark For Deletion checkbox --->      

       <td><input type="checkbox" name="deleteFileID" value="#getFiles.fileID#" /></td>





         <!--- isPressRelease checkbox --->      

       <td><cfinput type="checkbox" name="isPressReleaseID" value="#getFiles.fileID#" checked="#isPressRelease eq 1#"  /></td>







     </tr></cfoutput>



<!--- close loop through files called by query getFiles ---> 

     </cfloop>

     

   </table>



  <cfelse>

   <p><strong>At the moment, no files are attached to this document.</strong></p>

  </cfif>



<p><strong>Upload a <em>new</em> file: PDF, TEXT, DOC, DOCX, XLS, XLXS, or image files only:</strong> <a href="#" class="hintanchor" onMouseover="showhint('Browse your local computer disk to find a file to upload', this, event, '200px')">[?]</a></p>



  <!--- input field for file upload --->

  

<table class="tablecontrolpanel width600px">

				<tr><td>  

<cfinput type="file" size="25" accept="application/msexcel,application/msword,application/pdf,image/gif,image/jpeg,image/x-png" name="FileName" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'" maxlength="255" />

				</td>

	

    		<td>

   <p><strong>Enter File Link Text:</strong> <a href="#" class="hintanchor" onMouseover="showhint('What link text should the user click on to open this file?', this, event, '200px')">[?]</a><br />



   <cfinput type="Text"

            name="FileLinkText"

            value=""

            size="50"

            maxlength="100" /></p>

             </td></tr>

            </table>

            

            

           

           <!--- BEGIN ALIGN CENTER--->

   <div class="align-center">

   

   

   <!--- submit form to ColdFusion for processing; this is the DoSave function, which will add or edit a record --->

  <cfoutput>

    <input name="doSave" type="submit" value="#ButtonText#" class="btn" onMouseOver="this.className='btn btnhov'" onMouseOut="this.className='btn'" /> 

  </cfoutput>

  

  <span class="hintanchortext"><a href="#" class="hintanchor" onMouseover="showhint('Click the Update This Document button immediately left to apply your edits to this document', this, event, '200px')">[?]</a></span>

  

   

   

   

<cfif val(form.documentID)>



<hr />



<div class="graybox align-center width250px">

  <p>The button, below, deletes this document, its database record, and its associated files. Use deliberately and with caution.</p>

</div>





<!--- submit form to ColdFusion for processing; this is the DoDelete function, which deletes a Document record --->

<cfoutput>

  <input name="doDelete" type="submit" value="Delete This Document" class="btn" onMouseOver="this.className='btn btnhov'" onMouseOut="this.className='btn'" onclick="return confirm('Are you sure you wish to delete this document? After you delete it it is gone forever.')" />

</cfoutput>







<!--- END ALIGN CENTER --->

</div>

  



<cfelse>



</cfif>





<!--- END FORM --->

</cfform>





<!--- Page footer --->

<cfinclude template="/cep/cep_footer.cfm" />

Open in new window

Untitled-1.jpg
0
Comment
Question by:Eric Bourland
  • 29
  • 24
  • 6
59 Comments
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33482322
I have been thinking about this problem a lot today, off and on, while I do other tasks.

I wonder if I can set up a new CFIF statement:

<cfif isDefined("form.isPressReleaseID")> (assumes checkbox is checked)

.... do query to set isPressRelease = 1

<cfelse> (assumes checkbox is not checked)
... .... do query to set isPressRelease = 0

</cfif>

Is this a good idea? And, I would need to think about how to fit in this new CFIF statement among my many other CFIF statements.

EB
 <!--- SET OR UNSET A FILE TO isPressRelease ---> 

      <!--- this query must be placed within the Save Action ---> 

  

           <!--- begin CFELSEIF isDefined(form.isPressReleaseID) ---> 

                 <cfelseif isDefined("form.isPressReleaseID")> 

    

        <!---- query to set table tbl_CEP_Files, column isPressRelease to 1 or 0 ----> 

           <cfquery name="qry_updateisPressRelease" datasource="#ds#"> 

                        UPDATE tbl_CEP_Files 

                        SET isPressRelease = <cfqueryparam cfsqltype="cf_sql_bit" value="#Trim(form.isPressReleaseID)#"> 

                        WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#form.isPressReleaseID#" list="yes">) 

                </cfquery>  

Open in new window

0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33482413
Hi,

As you already set the default value for"isPressReleaseID", so i would suggest u that you no need  to
define condition,like isdefined("form.isPressReleaseID")

and to make more simplify code use CFPARAM.

<cfparam default="0" name="form.isPressRelease">

if u execute ur query directly then it will work.

Please check it.
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33482432
>>>As you already set the default value for"isPressReleaseID", so i would suggest u that you no need  to
define condition,like isdefined("form.isPressReleaseID")

This is a good observation and I will check this tomorrow, when I have had more sleep. =)

Thank you Brichsoft.

Eric
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33482524

Welcome Eric.

0
 
LVL 52

Expert Comment

by:_agx_
ID: 33484194
(no points please )

>> and to make more simplify code use CFPARAM.
>> <cfparam default="0" name="form.isPressRelease">

I agree.  

Personally that's how I prefer to handle checkboxes representing a true/false option.  Notice how the snippet below works without a bunch of isDefined() checks?


<!--- default is always 0 (ie false) --->
<cfparam name="form.isPressRelease" default="0">

<!--- debugging (only) --->
<cfoutput> debugging: form.isPressRelease = #form.isPressRelease#<br></cfoutput>


<form method="post">
      <!--- checkbox value is always 1 (ie true) --->
      isPressRelease <input type="checkbox" name="isPressRelease" value="1" <cfif form.isPressRelease>checked</cfif>>
      <input type="submit" name="test">
</form>
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33485867
_agx_ thank you. I am working on this task and will get back to you and Brichsoft later today. Hope you are well. EB
0
 
LVL 52

Expert Comment

by:_agx_
ID: 33486209
You're welcome.  I'm busy, but good :)  Hope you're doing well now too!

BTW: If Brichsoft's suggestion resolves the issue all points should go to him.  I just wanted to chime in and say I concur and thought it was a good suggestion ;-)

0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33486443

Thanks a lot Mr.Genius...........!!!!!!

I got my points from your comment.......

It feel good to get certifications.....but sometime some words do the same things. ;-)

Thanks again.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 33486540
>> but sometime some words do the same things

You're welcome :) I know what you mean!
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33490142
These notes, above, are really helpful. I've been doing a lot of experimenting!

OK. I'm able to mark a file as a press release -- but I am not able to unmark the file, making it not a press release. If I uncheck the isPressRelease checkbox and submit the update form, the database table column isPressRelease does not update. Hmm. I will try to explain what I am doing in this application. There are four parts:

0. Toward the beginning of the application I did:
<!--- default isPressRelease is 0 (false) --->
<cfparam name="form.isPressRelease" default="0">

1. Then, there is a query (line 569), which selects all columns from table tbl_CEP_files:

[code]
   <!--- query to get columns and values from tbl_CEP_files, for use below --->
<cfquery name="getFiles" datasource="#ds#">
    SELECT *
    FROM tbl_CEP_files
    WHERE DocumentID=<cfqueryparam value="#val(form.DocumentID)#" cfsqltype="cf_sql_integer">
    AND isDeleted = 0
  </cfquery>
[/code]

(Notice that files selected "belong" to a particular CEP document. That might or might not be important for the current task. I think for now it is not important. But wanted to explain the WHERE statement in the query above.)

2. Next, there is a checkbox (line 635):

 <!--- checkbox value is always 1 (ie true) --->
      <input type="checkbox" name="isPressRelease" value="1" <cfif form.isPressRelease>checked</cfif>>

3. Then, there is an update query that occurs within the "doSave"

[code]

    <!--- SET OR UNSET A FILE TO isPressRelease --->
      <!--- this query must be placed within the Save Action --->
 
             <!--- begin CFELSEIF isDefined(form.isPressRelease) --->
             <cfelseif isDefined("form.isPressRelease")>
   
      <!---- query to set table tbl_CEP_Files, column isPressRelease to 1 or 0 ---->
             <cfquery name="qry_updateisPressRelease" datasource="#ds#">
                         UPDATE tbl_CEP_Files
                       SET isPressRelease = <cfqueryparam cfsqltype="cf_sql_bit" value="#Trim(form.isPressRelease)#">
                    WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#form.isPressRelease#" list="yes">)
            </cfquery>
[/code]

I've been playing with different permutations of each of these three parts, above. The form currently is able to mark a file as a Press Release (isPressRelease = 1). But the form does not mark (isPressRelease = 0) even when I uncheck the check box.

What do you thin I am missing?

Thanks again for any advice.

Eric
<!---

Name:        insert_update.cfm

Author:      Eric B, following Ben Forta code in ColdFusion 8 web application construction kit; gdemaria; azadi; _agx_; Plucka; myselfrandhawa

Description: CEP add and update documents administration

Created:     2/24/2010 - 6/22/2010

ColdFusion Version 8

MS SQL Server 2005

--->





 <!--- Set default value for FileID in scope FORM --->

<cfparam name="form.FileID" default="">



 <!--- Set default value for NumberFiles in scope FORM --->

<cfparam name="form.NumberFiles" default="">



 <!--- Set default value for SelectDocumentTopics in scope FORM --->

<cfparam name="form.SelectDocumentTopics" default="0" />







 <!--- Set default value for DocumentID in scope URL --->

<cfparam name="URL.DocumentID" default="">



 <!--- Define DocumentID in scope FORM, then set form.DocumentID equal to the DocumentID passed in the URL: for use later in the application --->

<cfparam name="form.DocumentID" default="#URL.DocumentID#">







<!--- default isPressRelease is 0 (false) --->

<cfparam name="form.isPressRelease" default="0">









 <!--- Set datasource --->

 <cfset ds="ebwebwork">

  

 <!---- begin CFTRY; catch any errors, whether you throw them or the database does; and to test that file were uploaded successfully, or not  ---->

 <cftry>  

 



<!---- populate this with an error message ---->

<cfset variables.error = ""> 





        <!--- BEGIN: Save action --->





<!--- begin form.doSave --->



<!--- when the user clicks the Save Button, these events can occur: Add a document; Update a document; Delete a Document; Delete a file that is associated with a document --->



<cfif IsDefined("FORM.doSave")>





<!--- make sure that documentTitle and documentType are entered --->  

    

	<cfif len(form.DocumentTitle) eq 0>

			  <cfthrow message="Document Title is required">

	</cfif>

    

    <cfif len(form.DocumentType) eq 0>

			  <cfthrow message="Document Type is required">

	</cfif>





 <!--- in this query select NOTHING from table tbl_CEP_documents, and simply check if DocumentTitle exists --->

 

 <cfquery datasource="#ds#" name="CheckDocumentTitle">

  SELECT 'Nothing' FROM tbl_CEP_Documents

  WHERE DocumentTitle = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Form.DocumentTitle#">

  AND DocumentID <> <cfqueryparam cfsqltype="cf_sql_integer" value="#val(Form.DocumentID)#">

  </cfquery>

   

 

  

   <!--- if DocumentTitle exists, display error; refuse record insert --->

   

	<cfif CheckDocumentTitle.recordcount GT 0>

		   <cfthrow message="The Document Title is already taken; please enter another title">

	</cfif>

    

    <!--- begin statements to update, insert database records --->  

   

    <!--- begin cfif val(form.DocumentID) --->

    

    <!--- the action is UPDATE; a DocumentID Exists --->

    

				<cfif val(form.DocumentID)>

                

         

                

<!--- group three queries in a cftransaction: UPDATE Document; DELETE Document Topics; INSERT (new) Document Topics--->

<cftransaction>

    

  			  <cfquery name="UpdateDocument" datasource="#ds#">

				  UPDATE tbl_CEP_Documents

				  SET   DocumentTitle = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentTitle)#">,

					DocumentType = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentType)#">,

					DocumentAuthor = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentAuthor)#">,

				    DocumentAbstract = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentAbstract)#">,

				    DocumentPublicationDate = <cfqueryparam cfsqltype="cf_sql_date" value="#Trim(form.DocumentPublicationDate)#">,

				    DateRecordModified = <cfqueryparam cfsqltype="cf_sql_timestamp" value="#now()#">

				  WHERE DocumentID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.DocumentID)#">

			</cfquery>





<cfquery name="UpdateDocumentDeleteTopics" datasource="#ds#">

   DELETE FROM tbl_Document_Has_Topic

   WHERE DocumentID = <cfqueryparam value="#form.DocumentID#" cfsqltype="cf_sql_integer">

</cfquery>



<cfquery name="UpdateDocumentInsertNewTopics" datasource="#ds#">

INSERT INTO tbl_Document_Has_Topic

		(

        DocumentID

        ,  DocumentTopicID

        )

SELECT   <cfqueryparam value="#form.DocumentID#" cfsqltype="cf_sql_integer">

         , DocumentTopicID

FROM     tbl_CEP_Document_Topic

WHERE   DocumentTopicID  IN

(

<cfqueryparam value="#form.SelectDocumentTopics#" cfsqltype="cf_sql_integer" list="true">

)

</cfquery>

</cftransaction>







    <!--- CFELSE: DocumentID does not exist, then insert new document --->

				<cfelse> 

                

                

      <!--- use two queries: one to insert the record into tbl_CEP_Documents; one to insert DocumentID and DocumentTopicID into tbl_Document_Has_Topic  --->

      <!--- use cftransaction so both queries are processed together  --->

    

    

        <cftransaction>

	

				<!---- query to insert new document record into tbl_CEP_Documents ---->

					<cfquery name="InsertDocument" datasource="#ds#" result="newDocument">

				 INSERT INTO tbl_CEP_Documents

     					(

			            DocumentTitle,

            		    DocumentType,

                		DocumentAuthor,

		                DocumentAbstract,

        		        DocumentPublicationDate,

                		SSMA_TimeStamp

		                )

			     valueS(

						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentTitle)#">,

						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentType)#">,

						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentAuthor)#">,

						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentAbstract)#">,

						  <cfqueryparam cfsqltype="cf_sql_date" value="#Trim(form.DocumentPublicationDate)#">,

		     			  <cfqueryparam cfsqltype="cf_sql_timestamp" value="#now()#">

				         )         

					</cfquery>

                  

    <!--- cfquery to get the selected document topics, and insert them into tbl_Document_Has_Topic along with the document ID --->

            <cfquery name="InsertDocumentTopics" datasource="#ds#">

                 INSERT INTO tbl_Document_Has_Topic

                 		(

                        DocumentID,

                        DocumentTopicID

                        )

                  SELECT

                   <cfqueryparam value="#newDocument.IDENTITYCOL#" cfsqltype="cf_sql_integer">

                   , DocumentTopicID

                   FROM  tbl_CEP_Document_Topic

                   WHERE   DocumentTopicID  IN

                  (

                     <cfqueryparam value="#form.SelectDocumentTopics#" cfsqltype="cf_sql_integer" list="true">

                  )

               </cfquery>

        </cftransaction>     

             

                  

                    

	 <!--- use the result attribute value to set the form field value --->

      <cfset form.DocumentID = newDocument.IDENTITYCOL>



		<!--- END queries to update or insert database records ---> 



        <!--- END cfif val(form.DocumentID) -- if a document needed to be updated, or added, then it was done --->

					    </cfif>  

    

    

    

	   <!--- ============= BEGIN query to update column FileLinkText in tbl_CEP_Files ============= --->   

              <!--- this section must be placed within the Save Action --->  

 

        <cfloop index="kk" from="1" to="#val(form.numberFiles)#"> 

            <cfset form.updateFileLinkText = form['updateFileLinkText' & kk]>

            <cfset form.fileID = form['fileID' & kk]>

        

             <cfquery name="query_updateFileLinkText" datasource="#ds#">

                UPDATE tbl_CEP_Files

                SET FileLinkText = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.updateFileLinkText)#">

                WHERE FileID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.fileID)#">

             </cfquery>            

         

        </cfloop>

     

        <!--- ============= END query to update column FileLinkText in tbl_CEP_Files ============= --->   

    



    

<!--- remember cfif IsDefined("FORM.doSave") is still defined -- remember to close the cfif later --->

    

  

				<!--- test to see whether or not a file is being uploaded -- does form field FileName contain a file? --->         

  

		    	<!--- BEGIN: if form field FileName contains a file, then upload the file and the file's metadata --- this function updates the tbl_CEP_Files--->

      		<cfif form.fileName is not "">

     

              

			    <!--- BEGIN: upload a file using CFFILE --->       

     			<!--- cffile upload --->       

   			      <cffile action="upload" filefield="FileName" destination="c:\upload\cep-dc.org" nameconflict="overwrite">



			<cfif listFindNoCase("doc,docx,jpg,jpeg,png,gif,pdf,ppt,xls,xlsx,txt", cffile.serverFileExt) eq 0>

				    <cfthrow message="Your file did not upload. You may upload only permitted file types.">

			</cfif>

            



			<!---- query to insert new record into tbl_CEP_Files, with a file  (DOC, JPEG, PDF, etc.) to upload ---->

			<cfquery name="InsertFile" datasource="#ds#">

			 INSERT INTO tbl_CEP_Files

     			(

                DocumentID,

                FileName,

                FileLinkText,

				FileExtension,

				FileType,

				FileSize,

                isDeleted,

                isPressRelease

                )

		     valueS(

        		  <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.DocumentID)#">

				  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#cffile.clientFile#">

                  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.FileLinkText)#">

				  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#cffile.clientFileExt#">

				  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#cffile.contentType#">

				  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#cffile.fileSize#">

                  ,0

                  ,0

		           )         

				</cfquery>  

  

		   <!--- END query to insert new record into tbl_CEP_Files --->  

 

 



              <!--- SET OR UNSET A FILE TO isPressRelease --->

      <!--- this query must be placed within the Save Action --->

 

    	   <!--- begin CFELSEIF isDefined(form.isPressRelease) --->

		 <cfelseif isDefined("form.isPressRelease")>

   

	<!---- query to set table tbl_CEP_Files, column isPressRelease to 1 or 0 ---->

    	   <cfquery name="qry_updateisPressRelease" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET isPressRelease = <cfqueryparam cfsqltype="cf_sql_bit" value="#Trim(form.isPressRelease)#">

        		WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#form.isPressRelease#" list="yes">)

      		</cfquery>

  

  

           

              <!--- DELETE A FILE --->

      <!--- this query must be placed within the Save Action --->

 

    

    	   <!--- begin CFELSEIF isdefined(form.deleteFileID) --->

		 <cfelseif isDefined("form.deleteFileID")>        

   

	<!---- query to set a file to isDeleted = 1 ---->

    	   <cfquery name="qry_deleteFile" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET IsDeleted = 1

        		WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#form.deleteFileID#" list="yes">)

      		</cfquery>





            </cfif>

<!----- END form.fileName is not "" test to see if file is being uploaded ---->







	<!--- if insert record succeeded, and / or file upload succeeded, and / or FileLinkText were updated, then go to index page --->

				     <cflocation url="index.cfm" addtoken="no">



        

                    

    <!--- END: Save action --->

    



  

        <!--- BEGIN: Delete action --->





			   <!--- delete a database record --->

					   <!--- begin CFELSEIF isdefined(form.doDelete) --->

					        <cfelseif isDefined("form.doDelete")>        

					        <!---- query to delete record ---->

                            

                            <cftransaction>

					       	<cfquery name="DeleteDocument" datasource="#ds#">

					         DELETE FROM tbl_CEP_Documents

					         WHERE DocumentID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.DocumentID)#">

					        </cfquery>

                                                        

                            <cfquery name="UpdateDocumentDeleteTopics" datasource="#ds#">

							   DELETE FROM tbl_Document_Has_Topic

							   WHERE DocumentID = <cfqueryparam value="#form.DocumentID#" cfsqltype="cf_sql_integer">

							</cfquery>

                            </cftransaction>

              

 					        <!---- after delete, go to index page ---->

						 <cflocation url="index.cfm" addtoken="no">



	    <!--- END: Delete action --->

        

  



  <!--- END form.doSave --->

</cfif>











       <!--- this CFCATCH will trap errors -- the ones you threw or just regular database issues --->

<cfcatch type="Any">

     <cfset variables.error = cfcatch.message>

     <cfrethrow>

  </cfcatch>



  

  

  

		  <!--- END CFTRY --->  

			</cftry>







<!--- fetch the data from the database only when there are no errors.

      if an error exists, then let the form variables pass back into the form to display ---->

 

  <cfif len(variables.error) eq 0>

    

			  <!--- get data from table tbl_CEP_Documents and convert the data into form variables --->

			  <cfquery name="getDocumentDetails" datasource="#ds#">

				    select * from tbl_CEP_Documents where DocumentID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.DocumentID)#">

			  </cfquery>



  			<cfloop index="aCol" list="#getDocumentDetails.columnList#">

			       <cfset "form.#aCol#" = getDocumentDetails[aCol][getDocumentDetails.currentRow]>

			  </cfloop>

    

	</cfif>











<!--- BEGIN HTML / CSS PAGE HEADER --->

<cfinclude template="/cep/cep_header_admin.cfm" />









<!--- if there an error, display error in human readable form --->



<cfif len(variables.error)> 

			 <cfoutput>

			 <div style="border: 1px solid red; padding: 10px; margin:20px; width:400px;">#variables.error#</div>

			 </cfoutput>

</cfif>















				<!----- if record already exists (it will have an ID) then update it; otherwise, add new record... ----->

				<cfif val(form.documentID)>

					  <cfset FormTitle="Edit Document">

					  <cfset ButtonText="Update This Document">

  					  <cfset FileLinkTextButton="Update File Link Text">

				<cfelse>

						<cfset FormTitle="Add a Document">

						<cfset ButtonText="Add Document">



				</cfif>

                

                

                <!--- debugging (only) --->

<cfoutput> debugging: form.isPressRelease = #form.isPressRelease#<br></cfoutput>





  

				<!--- Add or Update Document Form begins here --->

				<cfform method="post" enctype="multipart/form-data" scriptsrc="#Request.CFFORM_JS_LIB#">





 <!--- Embed documentID (PK), fileID, numberFiles as hidden fields, to assign a value to each --->

 <cfoutput>

<input type="hidden" name="documentID" value="#form.documentID#" />



   </cfoutput>







  <cfoutput>



      <h2>#FormTitle#</h2>



  </cfoutput>

  

  

  <!--- BEGIN TABLE ADMIN; DISPLAY DOCUMENT DETAILS --->

 

<table class="table_admin">

<cfif val(form.documentID)>

 <tr>

  <td>

<p><strong>Document ID: <cfoutput>#URL.DocumentID#</cfoutput></strong></p>

  </td>

 </tr>

 <cfelse>

 </cfif>



 <tr>

  <td>

   <p><strong>Document Title</strong><br />



   <cfinput type="Text"

            name="DocumentTitle"

            value="#form.DocumentTitle#"

            message="Document title is required! Please restrict the Document title to 100 characters or fewer."

            required="Yes"

            validateAt="onSubmit,onServer"

            size="100"

            maxlength="250" /></p>

  </td>

 </tr>

 <tr>

  <td>

   <p><strong>Document Type</strong>  <a href="#" class="hintanchor" onMouseover="showhint('Don\'t worry too much about document type. Specify document type \'Report\' for most CEP documents.', this, event, '200px')">[?]</a></p>



   <select name="DocumentType" value="#form.DocumentType#">

   			<option value="Report">Report</option>

            <option value="Policy Brief">Policy Brief</option>

            <option value="Press Release">Press Release</option>

            <option value="Article">Article</option>

            <option value="Summary">Summary</option>

            <option value="Letter">Letter</option>

            <option value="Audio Transcript">Audio Transcript</option>

            <option value="Text Transcript">Text Transcript</option>

   </select>

  </td>

 </tr>





 <tr>

  <td>

   <p><strong>Document Author</strong><br />



   <cfinput type="Text"

            name="DocumentAuthor"

            value="#form.DocumentAuthor#"

            message="Enter Document Author Name"

            required="yes"

            validateAt="onSubmit,onServer"

            size="100"

            maxlength="100" /></p>

  </td>

 </tr>

 

 

<!--- this query requests values from columns DocumentTopicID and DocumentTopic in tbl_CEP_Document_Topics --->

 <cfquery datasource="#ds#" name="GetDocumentTopics">

SELECT DocumentTopicID, DocumentTopic

FROM tbl_CEP_Document_Topic

ORDER BY DocumentTopic

  </cfquery>

 

  <tr>

  <td>

    <p><strong>Assign this Document to CEP Topics</strong> <a href="#" class="hintanchor" onMouseover="showhint('Assign this document to a topic', this, event, '200px')">[?]</a></p>

    

    

      <p class="small">Choose at least one topic. To select more than one topic, hold the Ctrl or the Shift key (on your keyboard) and select topics with the mouse cursor.</p>

   



<!--- query to get existing topics for the current documentID --->



       <cfquery datasource="#ds#" name="GetSelectedTopics">

              SELECT DocumentTopicID

              FROM    tbl_Document_Has_Topic

              WHERE  DocumentID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.documentID)#">

       </cfquery>

     

       <!--- convert the DocumentTopicID values to a list --->

      <cfset form.SelectDocumentTopics = ValueList(GetSelectedTopics.DocumentTopicID)>



<cfselect name="SelectDocumentTopics"

size="8"

multiple="yes"

query="GetDocumentTopics"

queryPosition="below"

value="DocumentTopicID"

display="DocumentTopic"

selected="#form.SelectDocumentTopics#">

     <option value="0">Choose topic:</option>

</cfselect>

 

  </td>

 </tr>

 



 <tr>

  <td>

   <p><strong>Document Abstract</strong><br />

   <cfoutput>

   <textarea name="DocumentAbstract" wrap="virtual" style ="width:600px; height:250px;">#form.DocumentAbstract#</textarea>

   </cfoutput></p>

  </td>

 </tr>

 

 

 <tr>

  <td>

   <p><strong>Publication Date (use form MM/DD/YYYY; please click the calendar icon, below)</strong><br />

   <cfinput name="DocumentPublicationDate"

            value="#DateFormat(DocumentPublicationDate, "mm/dd/yyyy")#"

            message="Publication Date must be a valid date!"

            required="no"

            validate="usdate"

            validateAt="onSubmit,onServer"

            size="10"

            maxlength="10"

            type="datefield" mask="MM/DD/YYYY" /></p>

  </td>

 </tr>

 </table>



  <!--- END TABLE ADMIN; DISPLAY DOCUMENT DETAILS --->

  







   <!--- display the files currently associated with the document --->



<cfif val(form.documentID)>

<p>Below, please see the files currently associated with Document ID <strong><cfoutput>#URL.DocumentID#</cfoutput></strong>. If there are no files associated with the document, then no files will appear below. You have the option to upload a file (PDF, DOC, image file), which will associate the file with this document.</p>

<cfelse>

<p>This is a new document. You have the option to upload a file (PDF, DOC, image file), which will associate the file with this document.</p>

</cfif>





   <!--- query to get columns and values from tbl_CEP_files, for use below --->

<cfquery name="getFiles" datasource="#ds#">

    SELECT *

    FROM tbl_CEP_files

    WHERE DocumentID=<cfqueryparam value="#val(form.DocumentID)#" cfsqltype="cf_sql_integer"> 

    AND isDeleted = 0

  </cfquery>

  



  <cfif getFiles.recordCount>

   <table class="tablecontrolpanel width600px">

     <tr>

      <td><strong>File ID</strong></td>

      <td><strong>Files associated with this CEP document:</strong></td>

      <td><strong>File Link Text</strong> <a href="#" class="hintanchor" onMouseover="showhint('What link text should the user click on to open this file?', this, event, '200px')">[?]</a></td>

      <td><strong>Mark for Deletion</strong>  <a href="#" class="hintanchor" onMouseover="showhint('If you want this file to no longer associate with this document, you can mark the file for deletion; the file will be deleted from the server', this, event, '200px')">[?]</a></td>

      <td><strong>Press Release</strong>  <a href="#" class="hintanchor" onMouseover="showhint('Mark this file as a Press Release', this, event, '200px')">[?]</a></td>

      

     </tr>

     

     

    <!--- loop through files called by query getFiles ---> 

     <cfloop query="getFiles">

     

     

	  

	 <cfoutput>

     <input type="hidden" name="numberFiles" value="#getFiles.recordCount#">

          

     <cfif CurrentRow MOD 2 IS 1>

        <cfset bgcolor="##ffffff">

        <cfelse>

        <cfset bgcolor="##ebebeb">

      </cfif>

      

     <tr style="background-color:#bgcolor#">



        <!---  get list of file IDs --->  

       <td>#getFiles.FileID#</td>







        <!---  get list of file names --->  

       <td>#getFiles.FileName#</td>

       



        <!--- input field to update file link text --->   

        

        <cfset CTR = getFiles.currentRow>

          

       <td><cfinput type="Text"

            name="updateFileLinkText#CTR#"

            value="#getFiles.FileLinkText#"

            size="50"

            maxlength="100" />

            <input type="hidden" name="fileID#CTR#" value="#getFiles.fileID#" />

       </td>

               

      

         <!--- Mark For Deletion checkbox --->      

       <td><input type="checkbox" name="deleteFileID" value="#getFiles.fileID#" /></td>





         <!--- isPressRelease checkbox --->      

       <td>

       



 <!--- checkbox value is always 1 (ie true) --->

      <input type="checkbox" name="isPressRelease" value="1" <cfif form.isPressRelease>checked</cfif>>

       

<!---       <cfinput type="checkbox" name="isPressRelease" value="#getFiles.fileID#" checked="#isPressRelease eq 1#"  />---></td>







     </tr></cfoutput>



<!--- close loop through files called by query getFiles ---> 

     </cfloop>

     

   </table>



  <cfelse>

   <p><strong>At the moment, no files are attached to this document.</strong></p>

  </cfif>



<p><strong>Upload a <em>new</em> file: PDF, TEXT, DOC, DOCX, XLS, XLXS, or image files only:</strong> <a href="#" class="hintanchor" onMouseover="showhint('Browse your local computer disk to find a file to upload', this, event, '200px')">[?]</a></p>



  <!--- input field for file upload --->

  

<table class="tablecontrolpanel width600px">

				<tr><td>  

<cfinput type="file" size="25" accept="application/msexcel,application/msword,application/pdf,image/gif,image/jpeg,image/x-png" name="FileName" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'" maxlength="255" />

				</td>

	

    		<td>

   <p><strong>Enter File Link Text:</strong> <a href="#" class="hintanchor" onMouseover="showhint('What link text should the user click on to open this file?', this, event, '200px')">[?]</a><br />



   <cfinput type="Text"

            name="FileLinkText"

            value=""

            size="50"

            maxlength="100" /></p>

             </td></tr>

            </table>

            

            

           

           <!--- BEGIN ALIGN CENTER--->

   <div class="align-center">

   

   

   <!--- submit form to ColdFusion for processing; this is the DoSave function, which will add or edit a record --->

  <cfoutput>

    <input name="doSave" type="submit" value="#ButtonText#" class="btn" onMouseOver="this.className='btn btnhov'" onMouseOut="this.className='btn'" /> 

  </cfoutput>

  

  <span class="hintanchortext"><a href="#" class="hintanchor" onMouseover="showhint('Click the Update This Document button immediately left to apply your edits to this document', this, event, '200px')">[?]</a></span>

  

   

   

   

<cfif val(form.documentID)>



<hr />



<div class="graybox align-center width250px">

  <p>The button, below, deletes this document, its database record, and its associated files. Use deliberately and with caution.</p>

</div>





<!--- submit form to ColdFusion for processing; this is the DoDelete function, which deletes a Document record --->

<cfoutput>

  <input name="doDelete" type="submit" value="Delete This Document" class="btn" onMouseOver="this.className='btn btnhov'" onMouseOut="this.className='btn'" onclick="return confirm('Are you sure you wish to delete this document? After you delete it it is gone forever.')" />

</cfoutput>







<!--- END ALIGN CENTER --->

</div>

  



<cfelse>



</cfif>





<!--- END FORM --->

</cfform>





<!--- Page footer --->

<cfinclude template="/cep/cep_footer.cfm" />

Open in new window

0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33490716
Hi,

My observations are.........

1. this is not related with problem but still this can create trouble,
    Your checkbox are inside the loop,so when u submi the form there could be value like 1,1 [ As your checkbox name is same so it will treat as LIST and combine both values.]

<CFLOOP INDEX="i" FROM="1" TO="3">
<input TYPE="Checkbox" NAME="chk1" VALUE="1">Check Me<br>
</cfloop>

if u select any of two then value will be 1,1

2. Did you checked,your cfelseif condition getting satisfied? There could be possibility that its not coming there.....
    due to some sort of error in above line or <cfif form.fileName is not ""> getting satisfied,


- i created dummy code and its working properly.... ;-)
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33492096
I will try it out! More soon. Thank you! EB
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33493280
Brichsoft,

I think the isPressRelease checkbox needs to be inside the CFLOOP. Why is that? Because the CFLOOP loops through all files (PDFs) associated with a document.

If we take the isPressRelease checkbox out of the CFLOOP, then, how will ColdFusion know which file to mark TRUE or FALSE in column isPressRelease?

Does that make sense, or do I have the wrong idea? Am I missing something?

Eric
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33493411
Eric,

your idea is perfect.
but the thing is update query.

  <cfquery name="qry_updateisPressRelease" datasource="#ds#">
                         UPDATE tbl_CEP_Files
                       SET isPressRelease = <cfqueryparam cfsqltype="cf_sql_bit" value="#Trim(form.isPressReleaseID)#">
                    WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#form.isPressReleaseID#" list="yes">)
                  </cfquery>


here if u check two checkbox then value will be come as 1,1
so ur query will fails.

i will show u right way to update.

secondly like u stored d value for  
<input type="checkbox" name="deleteFileID" value="#getFiles.fileID#" />

same value #getFiles.fileID# u need to be store in checkbox
 <input type="checkbox" name="isPressRelease" value="#getFiles.fileID#" <cfif form.isPressRelease>checked</cfif>>

which u already did it previously
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33493436

now

as you having checkbox in a loop so neither cfparam will be useful nor ur previous condition as ur checkbox having the same name.

That is where update is not working.

so u need to do certain code change.

form.doc
0
 
LVL 19

Assisted Solution

by:Bhavesh Shah
Bhavesh Shah earned 250 total points
ID: 33493454

i attached document file because i marked the changes in bold.
please check that.

what I'm doing basically,
I'm resetting isPressRelease to 0 in query for that documentid and then setting up 1 for selected checkbox.

why because
suppose u have 3 files and u select any of two to mark as release,how you identify?

anyways u r smarty to understand my code.

look at the code and let me know if u have any doubt
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33493464
hey buddy,

i forget to mentioned one change in above code is that

if u want to check the checkbox after submitting then


<input type="checkbox" name="isPressRelease" value="#getFiles.fileID#" <cfif ListFind(form.isPressRelease,getFiles.fileID)>checked</cfif>>


Actually,I should tell u yesterday itself but somehow it didnt click @ that time.

Sory 4 late
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33496408
Dear Brichsoft,

That is extremely helpful. I am studying these code changes, and I will get back to you later today. As always, thank you. =) I hope your day is going well.

Eric
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33496810
Dear Brichsoft,

It is working! There is one small problem that I will ask you about, but the CEP insert_update.cfm application now sets, or resets isPressRelease to value 0 or 1. I see how your code works -- very clever. I have learned a lot from this task.

One note: I noticed that the IsDeleted query no longer worked. Then,  I moved the IsDeleted query before the isPressRelease query, and it works again. =) I attach the code below. This is working great.

The one small problem is, the isPressRelease checkbox does not remain checked, even when isPressRelease is True or 1.

I am working on different ideas to get the  isPressRelease checkbox to remain checked when isPressRelease is True or 1.

I am studying your note about: <input type="checkbox" name="isPressRelease" value="#getFiles.fileID#" <cfif ListFind(form.isPressRelease,getFiles.fileID)>checked</cfif>>

I will return later when I have more results.

Again, thank you. Hope you are well.

Eric
 	   <!--- begin CFELSEIF isdefined(form.deleteFileID) --->

		 <cfelseif isDefined("form.deleteFileID")>        

   

	<!---- query to set a file to isDeleted = 1 ---->

    	   <cfquery name="qry_deleteFile" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET IsDeleted = 1

        		WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#form.deleteFileID#" list="yes">)

      		</cfquery>





              <!--- SET OR UNSET A FILE TO isPressRelease --->

      <!--- this query must be placed within the Save Action --->

 

    	   <!--- begin CFELSEIF isDefined(form.isPressRelease) --->

		 <cfelseif isDefined("form.isPressRelease")>

   

   <!----query to reset table tbl_CEP_Files, column isPressRelease to 0 ---->

 			<cfquery name="qry_updateisPressRelease" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET isPressRelease = 0

        		WHERE DocumentID=<cfqueryparam value="#val(form.DocumentID)#" cfsqltype="cf_sql_integer"> 

    			AND isDeleted = 0

      		</cfquery>



	<!---- query to set table tbl_CEP_Files, column isPressRelease to 1 ---->

      	    <cfquery name="qry_updateisPressRelease" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET isPressRelease = 1

        		WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#form.isPressRelease#" list="yes">)

      		</cfquery>

Open in new window

0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33497965
Eric,

its really feel good to assist u.

Just for info,
 <cfelseif isDefined("form.isPressRelease")>
us always going to defined so u delete function never going to call.

My day just started from ur good wishes.

Thanks 4 ur wishes.
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33498407
Dear Brichsoft,

Good morning to you. (It is late night in Chicago.)

I think I know why the isPressRelease checkbox does not appear as checked, even when the record in the isPressRelease column is 1 or True. I think it might be the ListCase function. I read about ListCase here:

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_l_09.html

And it seems like ListCase returns only the first element in a list. But when a Press Release file is not the first file in a list of files, then I think ColdFusion ignores the Press Release file and does not mark the checkbox "checked".

Am I on the right track? I am trying to study and learn as much as I can before I bother you further. =)

Is there another function that we can use instead of ListCase?

   <!--- isPressRelease checkbox --->  

      <input type="checkbox" name="isPressRelease" value="#getFiles.fileID#" <cfif ListFind(form.isPressRelease,getFiles.fileID)>checked</cfif>>

(I am trying different ideas.)

Thank you again. I really appreciate your time. I hope your day has begun well.

Eric
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33498423
Hmmm. Maybe I should use ListContains. Trying that.... no, that was not the answer. ListFind does not do the trick either.

0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33498455
I think that value "form.isPressRelease" is not the same as delimiter "getFiles.fileID":

<input type="checkbox" name="isPressRelease" value="#getFiles.fileID#" <cfif ListFindNoCase(form.isPressRelease,getFiles.fileID)>checked</cfif>>

Do you think I need to change either the value or the delimiter?

Sorry to bombard you with responses and ideas. =) I am trying many different ideas.
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33498559

=) u r not bothering me,
chill..

ListFind should work.....how
let me explain.see,
when u giving same name to checkbox,it will return a list.

i make small example to explain this.
Pleaase look at it.


In your case, there could be blank spaces is coming or form.isPressRelease may not hold values.

To debug,

just print #form.isPressRelease#

so u come to know what it holds.

Have sound sleep =)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">



<html>

<head>

	<title>Untitled</title>

</head>



<body>



<CFOUTPUT>

<CFPARAM DEFAULT="" NAME="check1">



<FORM ACTION="CHCK.cfm" METHOD="post">



<CFSET fileID = "CF4,CF5,CF6,CF7,CF8">



<CFLOOP LIST="#fileID#" index="file1">

	<input TYPE="Checkbox" NAME="check1" VALUE="#file1#"<cfif listfind(check1,file1)>CHECKED</cfif>>#file1#<br>

</CFLOOP>



<cfif check1 is not "">selected values are #check1#</cfif>

	<input TYPE="Submit" NAME="submit" VALUE="Check">

</FORM>

</CFOUTPUT>

</body>

</html>

Open in new window

0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33503650
Brichsoft,

It is good to hear from you.

I test Test variable isPressRelease: #form.isPressRelease#

... and the output of #form.isPressRelease# is always: 0.

(As an aside I also set up the CHCK.cfm and I see how listfind works -- and I understand that ListFind should work to select the CEP files marked as isPressRelease. Thank you for that.)

So, I should use the ListFind function to select files marked isPressRelease.

But, ColdFusion thinks that no files are marked isPressRelease. Hmmm.

Up toward the beginning of the application I have this line:

<!--- default isPressRelease is 0 (false) --->
<cfparam name="form.isPressRelease" default="0">


and I wonder if that is a problem.

I am continuing to experiment with this problem. Thank you again for any advice. I hope your Monday was good.

Eric
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33504142

Dear Eric,

Good Morning..
Hope ur day goes well.
mine was ok kind.thanks

back to code.

about <cfparam name="form.isPressRelease" default="0">

hmmmm,i dont think dat will creating problem.
That will defined only your object is not defined.

can u pls post ur full code again....
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33504255
I really appreciate your time.
<!---

Name:        insert_update.cfm

Author:      Eric B, following Ben Forta code in ColdFusion 8 web application construction kit; gdemaria; azadi; _agx_; Plucka; myselfrandhawa; Brichsoft

Description: CEP add and update documents administration

Created:     2/24/2010 - 8/23/2010

ColdFusion Version 8

MS SQL Server 2005

--->





 <!--- Set default value for FileID in scope FORM --->

<cfparam name="form.FileID" default="">



 <!--- Set default value for NumberFiles in scope FORM --->

<cfparam name="form.NumberFiles" default="">



 <!--- Set default value for SelectDocumentTopics in scope FORM --->

<cfparam name="form.SelectDocumentTopics" default="0" />







 <!--- Set default value for DocumentID in scope URL --->

<cfparam name="URL.DocumentID" default="">



 <!--- Define DocumentID in scope FORM, then set form.DocumentID equal to the DocumentID passed in the URL: for use later in the application --->

<cfparam name="form.DocumentID" default="#URL.DocumentID#">







<!--- default isPressRelease is 0 (false) --->

<cfparam name="form.isPressRelease" default="0">









 <!--- Set datasource --->

 <cfset ds="ebwebwork">

  

 <!---- begin CFTRY; catch any errors, whether you throw them or the database does; and to test that file were uploaded successfully, or not  ---->

 <cftry>  

 



<!---- populate this with an error message ---->

<cfset variables.error = ""> 





        <!--- BEGIN: Save action --->





<!--- begin form.doSave --->



<!--- when the user clicks the Save Button, these events can occur: Add a document; Update a document; Delete a Document; Delete a file that is associated with a document --->



<cfif IsDefined("FORM.doSave")>





<!--- make sure that documentTitle and documentType are entered --->  

    

	<cfif len(form.DocumentTitle) eq 0>

			  <cfthrow message="Document Title is required">

	</cfif>

    

    <cfif len(form.DocumentType) eq 0>

			  <cfthrow message="Document Type is required">

	</cfif>





 <!--- in this query select NOTHING from table tbl_CEP_documents, and simply check if DocumentTitle exists --->

 

 <cfquery datasource="#ds#" name="CheckDocumentTitle">

  SELECT 'Nothing' FROM tbl_CEP_Documents

  WHERE DocumentTitle = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Form.DocumentTitle#">

  AND DocumentID <> <cfqueryparam cfsqltype="cf_sql_integer" value="#val(Form.DocumentID)#">

  </cfquery>

   

 

  

   <!--- if DocumentTitle exists, display error; refuse record insert --->

   

	<cfif CheckDocumentTitle.recordcount GT 0>

		   <cfthrow message="The Document Title is already taken; please enter another title">

	</cfif>

    

    <!--- begin statements to update, insert database records --->  

   

    <!--- begin cfif val(form.DocumentID) --->

    

    <!--- the action is UPDATE; a DocumentID Exists --->

    

				<cfif val(form.DocumentID)>

                

         

                

<!--- group three queries in a cftransaction: UPDATE Document; DELETE Document Topics; INSERT (new) Document Topics--->

<cftransaction>

    

  			  <cfquery name="UpdateDocument" datasource="#ds#">

				  UPDATE tbl_CEP_Documents

				  SET   DocumentTitle = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentTitle)#">,

					DocumentType = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentType)#">,

					DocumentAuthor = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentAuthor)#">,

				    DocumentAbstract = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentAbstract)#">,

				    DocumentPublicationDate = <cfqueryparam cfsqltype="cf_sql_date" value="#Trim(form.DocumentPublicationDate)#">,

				    DateRecordModified = <cfqueryparam cfsqltype="cf_sql_timestamp" value="#now()#">

				  WHERE DocumentID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.DocumentID)#">

			</cfquery>





<cfquery name="UpdateDocumentDeleteTopics" datasource="#ds#">

   DELETE FROM tbl_Document_Has_Topic

   WHERE DocumentID = <cfqueryparam value="#form.DocumentID#" cfsqltype="cf_sql_integer">

</cfquery>



<cfquery name="UpdateDocumentInsertNewTopics" datasource="#ds#">

INSERT INTO tbl_Document_Has_Topic

		(

        DocumentID

        ,  DocumentTopicID

        )

SELECT   <cfqueryparam value="#form.DocumentID#" cfsqltype="cf_sql_integer">

         , DocumentTopicID

FROM     tbl_CEP_Document_Topic

WHERE   DocumentTopicID  IN

(

<cfqueryparam value="#form.SelectDocumentTopics#" cfsqltype="cf_sql_integer" list="true">

)

</cfquery>

</cftransaction>







    <!--- CFELSE: DocumentID does not exist, then insert new document --->

				<cfelse> 

                

                

      <!--- use two queries: one to insert the record into tbl_CEP_Documents; one to insert DocumentID and DocumentTopicID into tbl_Document_Has_Topic  --->

      <!--- use cftransaction so both queries are processed together  --->

    

    

        <cftransaction>

	

				<!---- query to insert new document record into tbl_CEP_Documents ---->

					<cfquery name="InsertDocument" datasource="#ds#" result="newDocument">

				 INSERT INTO tbl_CEP_Documents

     					(

			            DocumentTitle,

            		    DocumentType,

                		DocumentAuthor,

		                DocumentAbstract,

        		        DocumentPublicationDate,

                		SSMA_TimeStamp

		                )

			     valueS(

						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentTitle)#">,

						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentType)#">,

						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentAuthor)#">,

						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentAbstract)#">,

						  <cfqueryparam cfsqltype="cf_sql_date" value="#Trim(form.DocumentPublicationDate)#">,

		     			  <cfqueryparam cfsqltype="cf_sql_timestamp" value="#now()#">

				         )         

					</cfquery>

                  

    <!--- cfquery to get the selected document topics, and insert them into tbl_Document_Has_Topic along with the document ID --->

            <cfquery name="InsertDocumentTopics" datasource="#ds#">

                 INSERT INTO tbl_Document_Has_Topic

                 		(

                        DocumentID,

                        DocumentTopicID

                        )

                  SELECT

                   <cfqueryparam value="#newDocument.IDENTITYCOL#" cfsqltype="cf_sql_integer">

                   , DocumentTopicID

                   FROM  tbl_CEP_Document_Topic

                   WHERE   DocumentTopicID  IN

                  (

                     <cfqueryparam value="#form.SelectDocumentTopics#" cfsqltype="cf_sql_integer" list="true">

                  )

               </cfquery>

        </cftransaction>     

             

                  

                    

	 <!--- use the result attribute value to set the form field value --->

      <cfset form.DocumentID = newDocument.IDENTITYCOL>



		<!--- END queries to update or insert database records ---> 



        <!--- END cfif val(form.DocumentID) -- if a document needed to be updated, or added, then it was done --->

					    </cfif>  

    

    

    

	   <!--- ============= BEGIN query to update column FileLinkText in tbl_CEP_Files ============= --->   

              <!--- this section must be placed within the Save Action --->  

 

        <cfloop index="kk" from="1" to="#val(form.numberFiles)#"> 

            <cfset form.updateFileLinkText = form['updateFileLinkText' & kk]>

            <cfset form.fileID = form['fileID' & kk]>

        

             <cfquery name="query_updateFileLinkText" datasource="#ds#">

                UPDATE tbl_CEP_Files

                SET FileLinkText = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.updateFileLinkText)#">

                WHERE FileID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.fileID)#">

             </cfquery>            

         

        </cfloop>

     

        <!--- ============= END query to update column FileLinkText in tbl_CEP_Files ============= --->   

    



    

<!--- remember cfif IsDefined("FORM.doSave") is still defined -- remember to close the cfif later --->

    

  

				<!--- test to see whether or not a file is being uploaded -- does form field FileName contain a file? --->         

  

		    	<!--- BEGIN: if form field FileName contains a file, then upload the file and the file's metadata --- this function updates the tbl_CEP_Files--->

      		<cfif form.fileName is not "">

     

              

			    <!--- BEGIN: upload a file using CFFILE --->       

     			<!--- cffile upload --->       

   			      <cffile action="upload" filefield="FileName" destination="c:\upload\cep-dc.org" nameconflict="overwrite">



			<cfif listFindNoCase("doc,docx,jpg,jpeg,png,gif,pdf,ppt,xls,xlsx,txt", cffile.serverFileExt) eq 0>

				    <cfthrow message="Your file did not upload. You may upload only permitted file types.">

			</cfif>

            



			<!---- query to insert new record into tbl_CEP_Files, with a file  (DOC, JPEG, PDF, etc.) to upload ---->

			<cfquery name="InsertFile" datasource="#ds#">

			 INSERT INTO tbl_CEP_Files

     			(

                DocumentID,

                FileName,

                FileLinkText,

				FileExtension,

				FileType,

				FileSize,

                isDeleted,

                isPressRelease

                )

		     valueS(

        		  <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.DocumentID)#">

				  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#cffile.clientFile#">

                  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.FileLinkText)#">

				  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#cffile.clientFileExt#">

				  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#cffile.contentType#">

				  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#cffile.fileSize#">

                  ,0

                  ,0

		           )         

				</cfquery>  

  

		   <!--- END query to insert new record into tbl_CEP_Files --->  

 

 

     

              <!--- DELETE A FILE --->

      <!--- this query must be placed within the Save Action --->

 

    

    	   <!--- begin CFELSEIF isdefined(form.deleteFileID) --->

		 <cfelseif isDefined("form.deleteFileID")>        

   

	<!---- query to set a file to isDeleted = 1 ---->

    	   <cfquery name="qry_deleteFile" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET IsDeleted = 1

        		WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#form.deleteFileID#" list="yes">)

      		</cfquery>





              <!--- SET OR UNSET A FILE TO isPressRelease --->

      <!--- this query must be placed within the Save Action --->

 

    	   <!--- begin CFELSEIF isDefined(form.isPressRelease) --->

		 <cfelseif isDefined("form.isPressRelease")>

   

   <!----query to reset table tbl_CEP_Files, column isPressRelease to 0 ---->

 			<cfquery name="qry_updateisPressRelease" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET isPressRelease = 0

        		WHERE DocumentID=<cfqueryparam value="#val(form.DocumentID)#" cfsqltype="cf_sql_integer"> 

    			AND isDeleted = 0

      		</cfquery>



	<!---- query to set table tbl_CEP_Files, column isPressRelease to 1 ---->

      	    <cfquery name="qry_updateisPressRelease" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET isPressRelease = 1

        		WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#form.isPressRelease#" list="yes">)

      		</cfquery>



  

    



            </cfif>

<!----- END form.fileName is not "" test to see if file is being uploaded ---->







	<!--- if insert record succeeded, and / or file upload succeeded, and / or FileLinkText were updated, then go to index page --->

				     <cflocation url="index.cfm" addtoken="no">



        

                    

    <!--- END: Save action --->

    



  

        <!--- BEGIN: Delete action --->





			   <!--- delete a database record --->

					   <!--- begin CFELSEIF isdefined(form.doDelete) --->

					        <cfelseif isDefined("form.doDelete")>        

					        <!---- query to delete record ---->

                            

                            <cftransaction>

					       	<cfquery name="DeleteDocument" datasource="#ds#">

					         DELETE FROM tbl_CEP_Documents

					         WHERE DocumentID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.DocumentID)#">

					        </cfquery>

                                                        

                            <cfquery name="UpdateDocumentDeleteTopics" datasource="#ds#">

							   DELETE FROM tbl_Document_Has_Topic

							   WHERE DocumentID = <cfqueryparam value="#form.DocumentID#" cfsqltype="cf_sql_integer">

							</cfquery>

                            </cftransaction>

              

 					        <!---- after delete, go to index page ---->

						 <cflocation url="index.cfm" addtoken="no">



	    <!--- END: Delete action --->

        

  



  <!--- END form.doSave --->

</cfif>











       <!--- this CFCATCH will trap errors -- the ones you threw or just regular database issues --->

<cfcatch type="Any">

     <cfset variables.error = cfcatch.message>

     <cfrethrow>

  </cfcatch>



  

  

  

		  <!--- END CFTRY --->  

			</cftry>







<!--- fetch the data from the database only when there are no errors.

      if an error exists, then let the form variables pass back into the form to display ---->

 

  <cfif len(variables.error) eq 0>

    

			  <!--- get data from table tbl_CEP_Documents and convert the data into form variables --->

			  <cfquery name="getDocumentDetails" datasource="#ds#">

				    select * from tbl_CEP_Documents where DocumentID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.DocumentID)#">

			  </cfquery>



  			<cfloop index="aCol" list="#getDocumentDetails.columnList#">

			       <cfset "form.#aCol#" = getDocumentDetails[aCol][getDocumentDetails.currentRow]>

			  </cfloop>

    

	</cfif>











<!--- BEGIN HTML / CSS PAGE HEADER --->

<cfinclude template="/cep/cep_header_admin.cfm" />









<!--- if there an error, display error in human readable form --->



<cfif len(variables.error)> 

			 <cfoutput>

			 <div style="border: 1px solid red; padding: 10px; margin:20px; width:400px;">#variables.error#</div>

			 </cfoutput>

</cfif>















				<!----- if record already exists (it will have an ID) then update it; otherwise, add new record... ----->

				<cfif val(form.documentID)>

					  <cfset FormTitle="Edit Document">

					  <cfset ButtonText="Update This Document">

  					  <cfset FileLinkTextButton="Update File Link Text">

				<cfelse>

						<cfset FormTitle="Add a Document">

						<cfset ButtonText="Add Document">



				</cfif>

                

                

  

				<!--- Add or Update Document Form begins here --->

				<cfform method="post" enctype="multipart/form-data" scriptsrc="#Request.CFFORM_JS_LIB#">





 <!--- Embed documentID (PK), fileID, numberFiles as hidden fields, to assign a value to each --->

 <cfoutput>

<input type="hidden" name="documentID" value="#form.documentID#" />



   </cfoutput>







  <cfoutput>



      <h2>#FormTitle#</h2>



  </cfoutput>

  

  

  <!--- BEGIN TABLE ADMIN; DISPLAY DOCUMENT DETAILS --->

 

<table class="table_admin">

<cfif val(form.documentID)>

 <tr>

  <td>

<p><strong>Document ID: <cfoutput>#URL.DocumentID#</cfoutput></strong></p>

  </td>

 </tr>

 <cfelse>

 </cfif>



 <tr>

  <td>

   <p><strong>Document Title</strong><br />



   <cfinput type="Text"

            name="DocumentTitle"

            value="#form.DocumentTitle#"

            message="Document title is required! Please restrict the Document title to 100 characters or fewer."

            required="Yes"

            validateAt="onSubmit,onServer"

            size="100"

            maxlength="250" /></p>

  </td>

 </tr>

 <tr>

  <td>

   <p><strong>Document Type</strong>  <a href="#" class="hintanchor" onMouseover="showhint('Don\'t worry too much about document type. Specify document type \'Report\' for most CEP documents.', this, event, '200px')">[?]</a></p>



   <select name="DocumentType" value="#form.DocumentType#">

   			<option value="Report">Report</option>

            <option value="Policy Brief">Policy Brief</option>

            <option value="Press Release">Press Release</option>

            <option value="Article">Article</option>

            <option value="Summary">Summary</option>

            <option value="Letter">Letter</option>

            <option value="Audio Transcript">Audio Transcript</option>

            <option value="Text Transcript">Text Transcript</option>

   </select>

  </td>

 </tr>





 <tr>

  <td>

   <p><strong>Document Author</strong><br />



   <cfinput type="Text"

            name="DocumentAuthor"

            value="#form.DocumentAuthor#"

            message="Enter Document Author Name"

            required="yes"

            validateAt="onSubmit,onServer"

            size="100"

            maxlength="100" /></p>

  </td>

 </tr>

 

 

<!--- this query requests values from columns DocumentTopicID and DocumentTopic in tbl_CEP_Document_Topics --->

 <cfquery datasource="#ds#" name="GetDocumentTopics">

SELECT DocumentTopicID, DocumentTopic

FROM tbl_CEP_Document_Topic

ORDER BY DocumentTopic

  </cfquery>

 

  <tr>

  <td>

    <p><strong>Assign this Document to CEP Topics</strong> <a href="#" class="hintanchor" onMouseover="showhint('Assign this document to a topic', this, event, '200px')">[?]</a></p>

    

    

      <p class="small">Choose at least one topic. To select more than one topic, hold the Ctrl or the Shift key (on your keyboard) and select topics with the mouse cursor.</p>

   



<!--- query to get existing topics for the current documentID --->



       <cfquery datasource="#ds#" name="GetSelectedTopics">

              SELECT DocumentTopicID

              FROM    tbl_Document_Has_Topic

              WHERE  DocumentID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.documentID)#">

       </cfquery>

     

       <!--- convert the DocumentTopicID values to a list --->

      <cfset form.SelectDocumentTopics = ValueList(GetSelectedTopics.DocumentTopicID)>



<cfselect name="SelectDocumentTopics"

size="8"

multiple="yes"

query="GetDocumentTopics"

queryPosition="below"

value="DocumentTopicID"

display="DocumentTopic"

selected="#form.SelectDocumentTopics#">

     <option value="0">Choose topic:</option>

</cfselect>

 

  </td>

 </tr>

 



 <tr>

  <td>

   <p><strong>Document Abstract</strong><br />

   <cfoutput>

   <textarea name="DocumentAbstract" wrap="virtual" style ="width:600px; height:250px;">#form.DocumentAbstract#</textarea>

   </cfoutput></p>

  </td>

 </tr>

 

 

 <tr>

  <td>

   <p><strong>Publication Date (use form MM/DD/YYYY; please click the calendar icon, below)</strong><br />

   <cfinput name="DocumentPublicationDate"

            value="#DateFormat(DocumentPublicationDate, "mm/dd/yyyy")#"

            message="Publication Date must be a valid date!"

            required="no"

            validate="usdate"

            validateAt="onSubmit,onServer"

            size="10"

            maxlength="10"

            type="datefield" mask="MM/DD/YYYY" /></p>

  </td>

 </tr>

 </table>



  <!--- END TABLE ADMIN; DISPLAY DOCUMENT DETAILS --->

  







   <!--- display the files currently associated with the document --->



<cfif val(form.documentID)>

<p>Below, please see the files currently associated with Document ID <strong><cfoutput>#URL.DocumentID#</cfoutput></strong>. If there are no files associated with the document, then no files will appear below. You have the option to upload a file (PDF, DOC, image file), which will associate the file with this document.</p>

<cfelse>

<p>This is a new document. You have the option to upload a file (PDF, DOC, image file), which will associate the file with this document.</p>

</cfif>





   <!--- query to get columns and values from tbl_CEP_files, for use below --->

<cfquery name="getFiles" datasource="#ds#">

    SELECT *

    FROM tbl_CEP_files

    WHERE DocumentID=<cfqueryparam value="#val(form.DocumentID)#" cfsqltype="cf_sql_integer"> 

    AND isDeleted = 0

  </cfquery>

  



  <cfif getFiles.recordCount>

   <table class="tablecontrolpanel width600px">

     <tr>

      <td><strong>File ID</strong></td>

      <td><strong>Files associated with this CEP document:</strong></td>

      <td><strong>File Link Text</strong> <a href="#" class="hintanchor" onMouseover="showhint('What link text should the user click on to open this file?', this, event, '200px')">[?]</a></td>

      <td><strong>Mark for Deletion</strong>  <a href="#" class="hintanchor" onMouseover="showhint('If you want this file to no longer associate with this document, you can mark the file for deletion; the file will be deleted from the server', this, event, '200px')">[?]</a></td>

          <td><strong>Press Release</strong>  <a href="#" class="hintanchor" onMouseover="showhint('Mark this file as a Press Release', this, event, '200px')">[?]</a></td>

         

     </tr>

     

     

    <!--- loop through files called by query getFiles ---> 

     <cfloop query="getFiles">

     

     

	  

	 <cfoutput>

     <input type="hidden" name="numberFiles" value="#getFiles.recordCount#">

          

     <cfif CurrentRow MOD 2 IS 1>

        <cfset bgcolor="##ffffff">

        <cfelse>

        <cfset bgcolor="##ebebeb">

      </cfif>

      

     <tr style="background-color:#bgcolor#">



        <!---  get list of file IDs --->  

       <td>#getFiles.FileID#</td>







        <!---  get list of file names --->  

       <td>#getFiles.FileName#</td>

       



        <!--- input field to update file link text --->   

        

        <cfset CTR = getFiles.currentRow>

          

       <td><cfinput type="Text"

            name="updateFileLinkText#CTR#"

            value="#getFiles.FileLinkText#"

            size="50"

            maxlength="100" />

            <input type="hidden" name="fileID#CTR#" value="#getFiles.fileID#" />

       </td>

               

      

         <!--- Mark For Deletion checkbox --->      

       <td><input type="checkbox" name="deleteFileID" value="#getFiles.fileID#" /></td>



     

       <td>

       

   <!--- isPressRelease checkbox --->  



      <input type="checkbox" name="isPressRelease" value="#getFiles.fileID#" <cfif ListFind(form.isPressRelease,getFiles.fileID)>checked</cfif>>

      

</td>







</tr>



       

   <!--- test to see the value that isPressRelease returns --->  



<tr><td>

Test variable isPressRelease</td>

<td colspan="4">

 #form.isPressRelease#

</td></tr>

    

     </cfoutput>



<!--- close loop through files called by query getFiles ---> 

     </cfloop>

   </table>



  <cfelse>

   <p><strong>At the moment, no files are attached to this document.</strong></p>

  </cfif>



<p><strong>Upload a <em>new</em> file: PDF, TEXT, DOC, DOCX, XLS, XLXS, or image files only:</strong> <a href="#" class="hintanchor" onMouseover="showhint('Browse your local computer disk to find a file to upload', this, event, '200px')">[?]</a></p>



  <!--- input field for file upload --->

  

<table class="tablecontrolpanel width600px">

				<tr><td>  

<cfinput type="file" size="25" accept="application/msexcel,application/msword,application/pdf,image/gif,image/jpeg,image/x-png" name="FileName" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'" maxlength="255" />

				</td>

	

    		<td>

   <p><strong>Enter File Link Text:</strong> <a href="#" class="hintanchor" onMouseover="showhint('What link text should the user click on to open this file?', this, event, '200px')">[?]</a><br />



   <cfinput type="Text"

            name="FileLinkText"

            value=""

            size="50"

            maxlength="100" /></p>

             </td></tr>

            </table>

            

            

           

           <!--- BEGIN ALIGN CENTER--->

   <div class="align-center">

   

   

   <!--- submit form to ColdFusion for processing; this is the DoSave function, which will add or edit a record --->

  <cfoutput>

    <input name="doSave" type="submit" value="#ButtonText#" class="btn" onMouseOver="this.className='btn btnhov'" onMouseOut="this.className='btn'" /> 

  </cfoutput>

  

  <span class="hintanchortext"><a href="#" class="hintanchor" onMouseover="showhint('Click the Update This Document button immediately left to apply your edits to this document', this, event, '200px')">[?]</a></span>

  

   

   

   

<cfif val(form.documentID)>



<hr />



<div class="graybox align-center width250px">

  <p>The button below deletes this document, its database record, and its associated files. Use deliberately and with caution.</p>

</div>





<!--- submit form to ColdFusion for processing; this is the DoDelete function, which deletes a Document record --->

<cfoutput>

  <input name="doDelete" type="submit" value="Delete This Document" class="btn" onMouseOver="this.className='btn btnhov'" onMouseOut="this.className='btn'" onclick="return confirm('Are you sure you wish to delete this document? After you delete it it is gone forever.')" />

</cfoutput>







<!--- END ALIGN CENTER --->

</div>

  



<cfelse>



</cfif>





<!--- END FORM --->

</cfform>





<!--- Page footer --->

<cfinclude template="/cep/cep_footer.cfm" />

Open in new window

0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33504805
I've been staring at this application for a long time and trying different ideas. What confuses me is the fact that we must select the isPressRelease from a ListFind value ... and I do not understand how to assign a "checked" value to that value. I am very curious to learn the solution to this.

I hope you do not spend too much time on this problem, Brichsoft. =)

Eric
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33507543
Eric

Its really good to assist u.so time is never be an issue.

ur code is perfectly ok.but problem is still there,right?
do following thing for debugging

1.After THIS LINE cfif IsDefined("FORM.doSave")>
Print this<CFDUMP VAR="#FORM#">

2.Temporary remove cfparam

3.if possible temporray,comment cftry & cfcatch

I'm sure ur update is also not working.
possibilities is some sort of hidden error is there,

Pls check above condition.

will get back to u in 3 hours

hope u enjoyed ur day.
Now I'm going to mine=)

Sweet Dreams in advance
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Author Comment

by:Eric Bourland
ID: 33508593
Dear Brichsoft,

I did as you said. I added:

<CFDUMP VAR="#FORM#">

and I removed the cfparam. But then I get this error:

Element ISPRESSRELEASE is undefined in FORM.  
 
 
The error occurred in C:\websites\ebwebwork.com\cep\admin\insert_update_test.cfm: line 645
Called from C:\websites\ebwebwork.com\cep\admin\insert_update_test.cfm: line 587
Called from C:\websites\ebwebwork.com\cep\admin\insert_update_test.cfm: line 417
Called from C:\websites\ebwebwork.com\cep\admin\insert_update_test.cfm: line 1
 
643 :    <!--- isPressRelease checkbox --->  
644 :
645 :       <input type="checkbox" name="isPressRelease" class="border0" value="#getFiles.fileID#" <cfif ListFind(form.isPressRelease,getFiles.fileID)>checked</cfif>>
646 :      
647 : </td>
 
I think ColdFusion demands the cfparam.

So, then, I put back the cfparam. And then I moved the CFDUMP to after the form. And the CFDUMP reports this output (see below).

So, we see that isPressRelease is always 0. Even when the document contains a file that is marked isPressRelease.

So I am not sure what to make of this.

Should I take away the CFTRY and CFCATCH?

Thank you again. I am going to get a few hours of sleep and will be back at my computer then. I hope your day is going well.

Best from Eric
[?] 

--------------------------------------------------------------------------------



The button below deletes this document, its database record, and its associated files. Use deliberately and with caution.

 

   

struct 

DATERECORDMODIFIED 2010-08-16 12:46:15.327  

DOCUMENTABSTRACT <p><b>Policy Brief 1: Basic Features</b> <br />A snapshot of main or basic features of state exit exams taken from the Center on Education Policy's August 2005 report, "STATE HIGH SCHOOL EXIT EXAMS: States Try Harder but Gaps Persist". <br />Published: December 01, 2005</p> <p><b>Policy Brief 2: Effects on Traditionally Underserved Students</b> <br />A snapshot of data on traditionally underserved students taken from the Center on Education Policy's August 2005 report, "STATE HIGH SCHOOL EXIT EXAMS: States Try Harder but Gaps Persist". <br />Published: January 01, 2006</p> <p><b>Policy Brief 3: Special Problems Affecting English Language Learners</b> <br />A snapshot of results on problems with English language learners in regard to exit exams taken from the Center on Education Policy's August 2005 report, "STATE HIGH SCHOOL EXIT EXAMS: States Try Harder but Gaps Persist". <br />Published: February 01, 2006 </p> <p><b>Policy Brief 4: Standards Differ from the No Child Left Behind Act</b> <br />A snapshot of results on differences between states' and of the No Child Left Behind Act's requirements on graduation taken from the Center on Education Policy's August 2005 report, "STATE HIGH SCHOOL EXIT EXAMS: States Try Harder but Gaps Persist". <br />Published: March 01, 2006</p>  

DOCUMENTAUTHOR Dalia Zabala  

DOCUMENTID 101  

DOCUMENTPUBLICATIONDATE [empty string]  

DOCUMENTTITLE State High School Exit Exams: 2006 Policy Briefs  

DOCUMENTTYPE Policy Brief  

FILEID [empty string]  

ISPRESSRELEASE 0  

NUMBERFILES [empty string]  

SELECTDOCUMENTTOPICS 7,19,25  

SSMA_TIMESTAMP 2010-08-02 13:29:44.17

Open in new window

0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33509063


Eric,

Your CFDUMP helped me.
CF doesnt demand CFPARAM.

its just because of checkbox is not defined so error is coming.

Check CFDUMP again.
I'm getting NUMBERFILES as [empty string]

Your code  <input type="hidden" name="numberFiles" value="#getFiles.recordCount#">

so check why this is coming as empty.

Secondly reset the browser caching/history as I'm doubting some caching issue.

Foolish QUESTION - You getting checkbox on screen?

Is it updating properly in database?
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33509262
Hi, Brichsoft,

It is 5:20 a.m. in Chicago and I cannot sleep. =) So I back at work on my ColdFusion task.

>>>You getting checkbox on screen?
Yes.

>>>Is it updating properly in database?
Also yes.

>>>Secondly reset the browser caching/history as I'm doubting some caching issue.
I will do .... I did. Still the same problem as before.

I see what you mean: variables NumberFiles and FileID are both empty. Even though, clearly, files are associated with the document.

Hmm.

Should I get rid of the CRPARAM? If so, should I use another way to make sure that variable isPressRelease always has some value?

What else can I do here to help us find out why variables NumberFiles and FileID are both empty?

Thank you again. =) I hope you are well.

Eric
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33509375


Eric,

I guess 2 days before i did same thing.I show ur msg through mobile around 5.30 in morning and then sit on pc and give u answer.
but you should take care of your health...........take proper rest.....u r more important then CF =)

back to code.

pls do 1 favor for me.
send me print screen of ur web page and send me view source of ur page.

I wish you do rest.

Today i'm in offfice for more 1 hour then i can contact you aftr 7 hours. [SORY 4 DAT]

My name is Bhavesh

- Bhavesh (Brichsoft)


0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33509461
Dear Bhavesh,

I am still awake. I have been poking at this code.

Here is my current code -- please see below. I have also attached a screenshot. See that the checkbox under Press Release is not checked next to file PressRelease_SchoolDistrictsARRAReport_071510.pdf, even though, in the database, this file is marked True for isPressRelease.

But, I have been looking at this code for a long time and -- it all looks right to me. The code make sense to me. It should be working but it is not. Frustrating. =)

Thank you so much again.

Best from Eric
<!---

Name:        insert_update.cfm

Author:      Eric B, following Ben Forta code in ColdFusion 8 web application construction kit; gdemaria; azadi; _agx_; Plucka; myselfrandhawa; Brichsoft

Description: CEP add and update documents administration

Created:     2/24/2010 - 8/23/2010

ColdFusion Version 8

MS SQL Server 2005

--->





 <!--- Set default value for FileID in scope FORM --->

<cfparam name="form.FileID" default="">



 <!--- Set default value for NumberFiles in scope FORM --->

<cfparam name="form.NumberFiles" default="">



 <!--- Set default value for SelectDocumentTopics in scope FORM --->

<cfparam name="form.SelectDocumentTopics" default="0" />







 <!--- Set default value for DocumentID in scope URL --->

<cfparam name="URL.DocumentID" default="">



 <!--- Define DocumentID in scope FORM, then set form.DocumentID equal to the DocumentID passed in the URL: for use later in the application --->

<cfparam name="form.DocumentID" default="#URL.DocumentID#">







<!--- default isPressRelease is 0 (false)--->

<cfparam name="form.isPressRelease" default="0"> 









 <!--- Set datasource --->

 <cfset ds="ebwebwork">

  

 <!---- begin CFTRY; catch any errors, whether you throw them or the database does; and to test that file were uploaded successfully, or not  ---->

 <cftry>  

 



<!---- populate this with an error message ---->

<cfset variables.error = ""> 





        <!--- BEGIN: Save action --->





<!--- begin form.doSave --->



<!--- when the user clicks the Save Button, these events can occur: Add a document; Update a document; Delete a Document; Delete a file that is associated with a document --->



<cfif IsDefined("FORM.doSave")>





<!--- make sure that documentTitle and documentType are entered --->  

    

	<cfif len(form.DocumentTitle) eq 0>

			  <cfthrow message="Document Title is required">

	</cfif>

    

    <cfif len(form.DocumentType) eq 0>

			  <cfthrow message="Document Type is required">

	</cfif>





 <!--- in this query select NOTHING from table tbl_CEP_documents, and simply check if DocumentTitle exists --->

 

 <cfquery datasource="#ds#" name="CheckDocumentTitle">

  SELECT 'Nothing' FROM tbl_CEP_Documents

  WHERE DocumentTitle = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Form.DocumentTitle#">

  AND DocumentID <> <cfqueryparam cfsqltype="cf_sql_integer" value="#val(Form.DocumentID)#">

  </cfquery>

   

 

  

   <!--- if DocumentTitle exists, display error; refuse record insert --->

   

	<cfif CheckDocumentTitle.recordcount GT 0>

		   <cfthrow message="The Document Title is already taken; please enter another title">

	</cfif>

    

    <!--- begin statements to update, insert database records --->  

   

    <!--- begin cfif val(form.DocumentID) --->

    

    <!--- the action is UPDATE; a DocumentID Exists --->

    

				<cfif val(form.DocumentID)>

                

         

                

<!--- group three queries in a cftransaction: UPDATE Document; DELETE Document Topics; INSERT (new) Document Topics--->

<cftransaction>

    

  			  <cfquery name="UpdateDocument" datasource="#ds#">

				  UPDATE tbl_CEP_Documents

				  SET   DocumentTitle = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentTitle)#">,

					DocumentType = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentType)#">,

					DocumentAuthor = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentAuthor)#">,

				    DocumentAbstract = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentAbstract)#">,

				    DocumentPublicationDate = <cfqueryparam cfsqltype="cf_sql_date" value="#Trim(form.DocumentPublicationDate)#">,

				    DateRecordModified = <cfqueryparam cfsqltype="cf_sql_timestamp" value="#now()#">

				  WHERE DocumentID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.DocumentID)#">

			</cfquery>





<cfquery name="UpdateDocumentDeleteTopics" datasource="#ds#">

   DELETE FROM tbl_Document_Has_Topic

   WHERE DocumentID = <cfqueryparam value="#form.DocumentID#" cfsqltype="cf_sql_integer">

</cfquery>



<cfquery name="UpdateDocumentInsertNewTopics" datasource="#ds#">

INSERT INTO tbl_Document_Has_Topic

		(

        DocumentID

        ,  DocumentTopicID

        )

SELECT   <cfqueryparam value="#form.DocumentID#" cfsqltype="cf_sql_integer">

         , DocumentTopicID

FROM     tbl_CEP_Document_Topic

WHERE   DocumentTopicID  IN

(

<cfqueryparam value="#form.SelectDocumentTopics#" cfsqltype="cf_sql_integer" list="true">

)

</cfquery>

</cftransaction>







    <!--- CFELSE: DocumentID does not exist, then insert new document --->

				<cfelse> 

                

                

      <!--- use two queries: one to insert the record into tbl_CEP_Documents; one to insert DocumentID and DocumentTopicID into tbl_Document_Has_Topic  --->

      <!--- use cftransaction so both queries are processed together  --->

    

    

        <cftransaction>

	

				<!---- query to insert new document record into tbl_CEP_Documents ---->

					<cfquery name="InsertDocument" datasource="#ds#" result="newDocument">

				 INSERT INTO tbl_CEP_Documents

     					(

			            DocumentTitle,

            		    DocumentType,

                		DocumentAuthor,

		                DocumentAbstract,

        		        DocumentPublicationDate,

                		SSMA_TimeStamp

		                )

			     valueS(

						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentTitle)#">,

						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentType)#">,

						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentAuthor)#">,

						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.DocumentAbstract)#">,

						  <cfqueryparam cfsqltype="cf_sql_date" value="#Trim(form.DocumentPublicationDate)#">,

		     			  <cfqueryparam cfsqltype="cf_sql_timestamp" value="#now()#">

				         )         

					</cfquery>

                  

    <!--- cfquery to get the selected document topics, and insert them into tbl_Document_Has_Topic along with the document ID --->

            <cfquery name="InsertDocumentTopics" datasource="#ds#">

                 INSERT INTO tbl_Document_Has_Topic

                 		(

                        DocumentID,

                        DocumentTopicID

                        )

                  SELECT

                   <cfqueryparam value="#newDocument.IDENTITYCOL#" cfsqltype="cf_sql_integer">

                   , DocumentTopicID

                   FROM  tbl_CEP_Document_Topic

                   WHERE   DocumentTopicID  IN

                  (

                     <cfqueryparam value="#form.SelectDocumentTopics#" cfsqltype="cf_sql_integer" list="true">

                  )

               </cfquery>

        </cftransaction>     

             

                  

                    

	 <!--- use the result attribute value to set the form field value --->

      <cfset form.DocumentID = newDocument.IDENTITYCOL>



		<!--- END queries to update or insert database records ---> 



        <!--- END cfif val(form.DocumentID) -- if a document needed to be updated, or added, then it was done --->

					    </cfif>  

    

    

    

	   <!--- ============= BEGIN query to update column FileLinkText in tbl_CEP_Files ============= --->   

              <!--- this section must be placed within the Save Action --->  

 

        <cfloop index="kk" from="1" to="#val(form.numberFiles)#"> 

            <cfset form.updateFileLinkText = form['updateFileLinkText' & kk]>

            <cfset form.fileID = form['fileID' & kk]>

        

             <cfquery name="query_updateFileLinkText" datasource="#ds#">

                UPDATE tbl_CEP_Files

                SET FileLinkText = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.updateFileLinkText)#">

                WHERE FileID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.fileID)#">

             </cfquery>            

         

        </cfloop>

     

        <!--- ============= END query to update column FileLinkText in tbl_CEP_Files ============= --->   

    



    

<!--- remember cfif IsDefined("FORM.doSave") is still defined -- remember to close the cfif later --->

    

  

				<!--- test to see whether or not a file is being uploaded -- does form field FileName contain a file? --->         

  

		    	<!--- BEGIN: if form field FileName contains a file, then upload the file and the file's metadata --- this function updates the tbl_CEP_Files--->

      		<cfif form.fileName is not "">

     

              

			    <!--- BEGIN: upload a file using CFFILE --->       

     			<!--- cffile upload --->       

   			      <cffile action="upload" filefield="FileName" destination="c:\upload\cep-dc.org" nameconflict="overwrite">



			<cfif listFindNoCase("doc,docx,jpg,jpeg,png,gif,pdf,ppt,xls,xlsx,txt", cffile.serverFileExt) eq 0>

				    <cfthrow message="Your file did not upload. You may upload only permitted file types.">

			</cfif>

            



			<!---- query to insert new record into tbl_CEP_Files, with a file  (DOC, JPEG, PDF, etc.) to upload ---->

			<cfquery name="InsertFile" datasource="#ds#">

			 INSERT INTO tbl_CEP_Files

     			(

                DocumentID,

                FileName,

                FileLinkText,

				FileExtension,

				FileType,

				FileSize,

                isDeleted,

                isPressRelease

                )

		     valueS(

        		  <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.DocumentID)#">

				  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#cffile.clientFile#">

                  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#Trim(form.FileLinkText)#">

				  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#cffile.clientFileExt#">

				  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#cffile.contentType#">

				  ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#cffile.fileSize#">

                  ,0

                  ,0

		           )         

				</cfquery>  

  

		   <!--- END query to insert new record into tbl_CEP_Files --->  

 

 

     

              <!--- DELETE A FILE --->

      <!--- this query must be placed within the Save Action --->

 

    

    	   <!--- begin CFELSEIF isdefined(form.deleteFileID) --->

		 <cfelseif isDefined("form.deleteFileID")>        

   

	<!---- query to set a file to isDeleted = 1 ---->

    	   <cfquery name="qry_deleteFile" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET IsDeleted = 1

        		WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#form.deleteFileID#" list="yes">)

      		</cfquery>





              <!--- SET OR UNSET A FILE TO isPressRelease --->

      <!--- this query must be placed within the Save Action --->

 

    	   <!--- begin CFELSEIF isDefined(form.isPressRelease) --->

		 <cfelseif isDefined("form.isPressRelease")>

   

   <!----query to reset table tbl_CEP_Files, column isPressRelease to 0 ---->

 			<cfquery name="qry_updateisPressRelease" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET isPressRelease = 0

        		WHERE DocumentID=<cfqueryparam value="#val(form.DocumentID)#" cfsqltype="cf_sql_integer"> 

    			AND isDeleted = 0

      		</cfquery>



	<!---- query to set table tbl_CEP_Files, column isPressRelease to 1 ---->

      	    <cfquery name="qry_updateisPressRelease" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET isPressRelease = 1

        		WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.isPressRelease)#" list="yes">)

      		</cfquery>



  

    



            </cfif>

<!----- END form.fileName is not "" test to see if file is being uploaded ---->







	<!--- if insert record succeeded, and / or file upload succeeded, and / or FileLinkText were updated, then go to index page --->

				     <cflocation url="index.cfm" addtoken="no">



        

                    

    <!--- END: Save action --->

    



  

        <!--- BEGIN: Delete action --->





			   <!--- delete a database record --->

					   <!--- begin CFELSEIF isdefined(form.doDelete) --->

					        <cfelseif isDefined("form.doDelete")>        

					        <!---- query to delete record ---->

                            

                            <cftransaction>

					       	<cfquery name="DeleteDocument" datasource="#ds#">

					         DELETE FROM tbl_CEP_Documents

					         WHERE DocumentID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.DocumentID)#">

					        </cfquery>

                                                        

                            <cfquery name="UpdateDocumentDeleteTopics" datasource="#ds#">

							   DELETE FROM tbl_Document_Has_Topic

							   WHERE DocumentID = <cfqueryparam value="#form.DocumentID#" cfsqltype="cf_sql_integer">

							</cfquery>

                            </cftransaction>

              

 					        <!---- after delete, go to index page ---->

						 <cflocation url="index.cfm" addtoken="no">



	    <!--- END: Delete action --->

        

  



  <!--- END form.doSave --->

</cfif>











       <!--- this CFCATCH will trap errors -- the ones you threw or just regular database issues --->

<cfcatch type="Any">

     <cfset variables.error = cfcatch.message>

     <cfrethrow>

  </cfcatch>



  

  

  

		  <!--- END CFTRY --->  

			</cftry>







<!--- fetch the data from the database only when there are no errors.

      if an error exists, then let the form variables pass back into the form to display ---->

 

  <cfif len(variables.error) eq 0>

    

			  <!--- get data from table tbl_CEP_Documents and convert the data into form variables --->

			  <cfquery name="getDocumentDetails" datasource="#ds#">

				    select * from tbl_CEP_Documents where DocumentID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.DocumentID)#">

			  </cfquery>



  			<cfloop index="aCol" list="#getDocumentDetails.columnList#">

			       <cfset "form.#aCol#" = getDocumentDetails[aCol][getDocumentDetails.currentRow]>

			  </cfloop>

    

	</cfif>











<!--- BEGIN HTML / CSS PAGE HEADER --->

<cfinclude template="/cep/cep_header_admin.cfm" />









<!--- if there an error, display error in human readable form --->



<cfif len(variables.error)> 

			 <cfoutput>

			 <div style="border: 1px solid red; padding: 10px; margin:20px; width:400px;">#variables.error#</div>

			 </cfoutput>

</cfif>















				<!----- if record already exists (it will have an ID) then update it; otherwise, add new record... ----->

				<cfif val(form.documentID)>

					  <cfset FormTitle="Edit Document">

					  <cfset ButtonText="Update This Document">

  					  <cfset FileLinkTextButton="Update File Link Text">

				<cfelse>

						<cfset FormTitle="Add a Document">

						<cfset ButtonText="Add Document">



				</cfif>

                

                

  

				<!--- Add or Update Document Form begins here --->

				<cfform method="post" enctype="multipart/form-data" scriptsrc="#Request.CFFORM_JS_LIB#">





 <!--- Embed documentID (PK), fileID, numberFiles as hidden fields, to assign a value to each --->

 <cfoutput>

<input type="hidden" name="documentID" value="#form.documentID#" />



   </cfoutput>







  <cfoutput>



      <h2>#FormTitle#</h2>



  </cfoutput>

  

  

  <!--- BEGIN TABLE ADMIN; DISPLAY DOCUMENT DETAILS --->

 

<table class="table_admin">

<cfif val(form.documentID)>

 <tr>

  <td>

<p><strong>Document ID: <cfoutput>#URL.DocumentID#</cfoutput></strong></p>

  </td>

 </tr>

 <cfelse>

 </cfif>



 <tr>

  <td>

   <p><strong>Document Title</strong><br />



   <cfinput type="Text"

            name="DocumentTitle"

            value="#form.DocumentTitle#"

            message="Document title is required! Please restrict the Document title to 100 characters or fewer."

            required="Yes"

            validateAt="onSubmit,onServer"

            size="100"

            maxlength="250" /></p>

  </td>

 </tr>

 <tr>

  <td>

   <p><strong>Document Type</strong>  <a href="#" class="hintanchor" onMouseover="showhint('Don\'t worry too much about document type. Specify document type \'Report\' for most CEP documents.', this, event, '200px')">[?]</a></p>



   <select name="DocumentType" value="#form.DocumentType#">

   			<option value="Report">Report</option>

            <option value="Policy Brief">Policy Brief</option>

            <option value="Press Release">Press Release</option>

            <option value="Article">Article</option>

            <option value="Summary">Summary</option>

            <option value="Letter">Letter</option>

            <option value="Letter">Pamphlet</option>

            <option value="Letter">Information Bulletin</option>

            <option value="Audio Transcript">Audio Transcript</option>

            <option value="Text Transcript">Text Transcript</option>

   </select>

  </td>

 </tr>





 <tr>

  <td>

   <p><strong>Document Author</strong><br />



   <cfinput type="Text"

            name="DocumentAuthor"

            value="#form.DocumentAuthor#"

            message="Enter Document Author Name"

            required="yes"

            validateAt="onSubmit,onServer"

            size="100"

            maxlength="100" /></p>

  </td>

 </tr>

 

 

<!--- this query requests values from columns DocumentTopicID and DocumentTopic in tbl_CEP_Document_Topics --->

 <cfquery datasource="#ds#" name="GetDocumentTopics">

SELECT DocumentTopicID, DocumentTopic

FROM tbl_CEP_Document_Topic

ORDER BY DocumentTopic

  </cfquery>

 

  <tr>

  <td>

    <p><strong>Assign this Document to CEP Topics</strong> <a href="#" class="hintanchor" onMouseover="showhint('Assign this document to a topic', this, event, '200px')">[?]</a></p>

    

    

      <p class="small">Choose at least one topic. To select more than one topic, hold the Ctrl or the Shift key (on your keyboard) and select topics with the mouse cursor.</p>

   



<!--- query to get existing topics for the current documentID --->



       <cfquery datasource="#ds#" name="GetSelectedTopics">

              SELECT DocumentTopicID

              FROM    tbl_Document_Has_Topic

              WHERE  DocumentID = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.documentID)#">

       </cfquery>

     

       <!--- convert the DocumentTopicID values to a list --->

      <cfset form.SelectDocumentTopics = ValueList(GetSelectedTopics.DocumentTopicID)>



<cfselect name="SelectDocumentTopics"

size="8"

multiple="yes"

query="GetDocumentTopics"

queryPosition="below"

value="DocumentTopicID"

display="DocumentTopic"

selected="#form.SelectDocumentTopics#">

     <option value="0">Choose topic:</option>

</cfselect>

 

  </td>

 </tr>

 



 <tr>

  <td>

   <p><strong>Document Abstract</strong><br />

   <cfoutput>

   <textarea name="DocumentAbstract" wrap="virtual" style ="width:600px; height:250px;">#form.DocumentAbstract#</textarea>

   </cfoutput></p>

  </td>

 </tr>

 

 

 <tr>

  <td>

   <p><strong>Publication Date (use form MM/DD/YYYY; please click the calendar icon, below)</strong><br />

   <cfinput name="DocumentPublicationDate"

            value="#DateFormat(DocumentPublicationDate, "mm/dd/yyyy")#"

            message="Publication Date must be a valid date!"

            required="no"

            validate="usdate"

            validateAt="onSubmit,onServer"

            size="10"

            maxlength="10"

            type="datefield" mask="MM/DD/YYYY" /></p>

  </td>

 </tr>

 </table>



  <!--- END TABLE ADMIN; DISPLAY DOCUMENT DETAILS --->

  







   <!--- display the files currently associated with the document --->



<cfif val(form.documentID)>

<p>Below, please see the files currently associated with Document ID <strong><cfoutput>#URL.DocumentID#</cfoutput></strong>. If there are no files associated with the document, then no files will appear below. You have the option to upload a file (PDF, DOC, image file), which will associate the file with this document.</p>

<cfelse>

<p>This is a new document. You have the option to upload a file (PDF, DOC, image file), which will associate the file with this document.</p>

</cfif>





   <!--- query to get columns and values from tbl_CEP_files, for use below --->

<cfquery name="getFiles" datasource="#ds#">

    SELECT *

    FROM tbl_CEP_files

    WHERE DocumentID=<cfqueryparam value="#val(form.DocumentID)#" cfsqltype="cf_sql_integer"> 

    AND isDeleted = 0

  </cfquery>

  



  <cfif getFiles.recordCount>

   <table class="tablecontrolpanel width600px">

     <tr>

      <td><strong>File ID</strong></td>

      <td><strong>Files associated with this CEP document:</strong></td>

      <td><strong>File Link Text</strong> <a href="#" class="hintanchor" onMouseover="showhint('What link text should the user click on to open this file?', this, event, '200px')">[?]</a></td>

      <td><strong>Mark for Deletion</strong>  <a href="#" class="hintanchor" onMouseover="showhint('If you want this file to no longer associate with this document, you can mark the file for deletion; the file will be deleted from the server', this, event, '200px')">[?]</a></td>

          <td><strong>Press Release</strong>  <a href="#" class="hintanchor" onMouseover="showhint('Mark this file as a Press Release', this, event, '200px')">[?]</a></td>

         

     </tr>

     

     

    <!--- loop through files called by query getFiles ---> 

     <cfloop query="getFiles">

     

     

	  

	 <cfoutput>

     <input type="hidden" name="numberFiles" value="#getFiles.recordCount#">

          

     <cfif CurrentRow MOD 2 IS 1>

        <cfset bgcolor="##ffffff">

        <cfelse>

        <cfset bgcolor="##ebebeb">

      </cfif>

      

     <tr style="background-color:#bgcolor#">



        <!---  get list of file IDs --->  

       <td>#getFiles.FileID#</td>







        <!---  get list of file names --->  

       <td>#getFiles.FileName#</td>

       



        <!--- input field to update file link text --->   

        

        <cfset CTR = getFiles.currentRow>

          

       <td><cfinput type="Text"

            name="updateFileLinkText#CTR#"

            value="#getFiles.FileLinkText#"

            size="50"

            maxlength="100" />

            <input type="hidden" name="fileID#CTR#" value="#getFiles.fileID#" />

       </td>

               

      

         <!--- Mark For Deletion checkbox --->      

       <td><input type="checkbox" name="deleteFileID" value="#getFiles.fileID#" class="border0" /></td>



     

       <td>

       

   <!--- isPressRelease checkbox --->  



      <input type="checkbox" name="isPressRelease" class="border0" value="#getFiles.fileID#" <cfif ListFind(form.isPressRelease,getFiles.fileID)>checked</cfif>>

      

</td>







</tr>





    

     </cfoutput>



<!--- close loop through files called by query getFiles ---> 

     </cfloop>

   </table>



  <cfelse>

   <p><strong>At the moment, no files are attached to this document.</strong></p>

  </cfif>



<p><strong>Upload a <em>new</em> file: PDF, TEXT, DOC, DOCX, XLS, XLXS, or image files only:</strong> <a href="#" class="hintanchor" onMouseover="showhint('Browse your local computer disk to find a file to upload', this, event, '200px')">[?]</a>



  <!--- input field for file upload --->

  



<cfinput type="file" size="25" accept="application/msexcel,application/msword,application/pdf,image/gif,image/jpeg,image/x-png" name="FileName" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'" maxlength="255" />

			</p>

            

        <!--- input field for file link text --->      

   <p><strong>Enter File Link Text:</strong> <a href="#" class="hintanchor" onMouseover="showhint('What link text should the user click on to open this file?', this, event, '200px')">[?]</a><br />



   <cfinput type="Text"

            name="FileLinkText"

            value=""

            size="50"

            maxlength="100" /></p>

       

            

            

           

           <!--- BEGIN ALIGN CENTER--->

   <div class="align-center">

   

   

   <!--- submit form to ColdFusion for processing; this is the DoSave function, which will add or edit a record --->

  <cfoutput>

    <input name="doSave" type="submit" value="#ButtonText#" class="btn" onMouseOver="this.className='btn btnhov'" onMouseOut="this.className='btn'" /> 

  </cfoutput>

  

  <span class="hintanchortext"><a href="#" class="hintanchor" onMouseover="showhint('Click the Update This Document button immediately left to apply your edits to this document', this, event, '200px')">[?]</a></span>

  

   

   

   

<cfif val(form.documentID)>



<hr />



<div class="graybox align-center width250px">

  <p>The button below deletes this document, its database record, and its associated files. Use deliberately and with caution.</p>

</div>





<!--- submit form to ColdFusion for processing; this is the DoDelete function, which deletes a Document record --->

<cfoutput>

  <input name="doDelete" type="submit" value="Delete This Document" class="btn" onMouseOver="this.className='btn btnhov'" onMouseOut="this.className='btn'" onclick="return confirm('Are you sure you wish to delete this document? After you delete it it is gone forever.')" />

</cfoutput>







<!--- END ALIGN CENTER --->

</div>

  



<cfelse>



</cfif>





<!--- END FORM --->

</cfform>



<CFDUMP VAR="#FORM#">





<!--- Page footer --->

<cfinclude template="/cep/cep_footer.cfm" />

Open in new window

Untitled-1.gif
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33509646
Eric,

Please give me view source of web page(Right click on browser  and view source) not the code.

I want to see HTML form.

Bhavesh
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33509756
Eric,

I'm trying to solve ur problem from last 4 days but some how some where your problem is not resolved.

E.E. is famour for Quick solution.

so anytime you feel,I'm not able to solve your problem then please click on "Request Attention"

Your work is more valuable. =)

- Bhavesh
p.s. I WANTED TO SOLVE YOUR PROBLEM, BUT NOT ON THE COST OF YOUR TIME.
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33513838
Dear Bhavesh,

I attach the source code, below.

It is indeed a perplexing problem!

I really appreciate your time and patience. You have been so generous and thoughtful.

Can you gather any insight or information from the source code?

I have stared at this code for a long time -- it looks like it should work! =)

Eric
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

 

<head><script type="text/javascript">_cf_loadingtexthtml="<img alt=' ' src='http://76.12.181.86/CFIDE/scripts/ajax/resources/cf/images/loading.gif'/>";

_cf_contextpath="";

_cf_ajaxscriptsrc="http://76.12.181.86/CFIDE/scripts/ajax";

_cf_jsonprefix='//';

_cf_clientid='95D592C458FFDDAD147E0584623C7BF3';</script><script type="text/javascript" src="http://76.12.181.86/CFIDE/scripts/ajax/yui/yahoo-dom-event/yahoo-dom-event.js"></script>

<script type="text/javascript" src="http://76.12.181.86/CFIDE/scripts/ajax/messages/cfmessage.js"></script>

<script type="text/javascript" src="http://76.12.181.86/CFIDE/scripts/ajax/package/cfajax.js"></script>

<script type="text/javascript" src="http://76.12.181.86/CFIDE/scripts/ajax/package/cfcalendar.js"></script>

<script type="text/javascript" src="http://76.12.181.86/CFIDE/scripts/ajax/ext/build/util/Date-min.js"></script>

<script type="text/javascript" src="http://76.12.181.86/CFIDE/scripts/ajax/yui/animation/animation-min.js"></script>

<script type="text/javascript" src="http://76.12.181.86/CFIDE/scripts/ajax/yui/calendar/calendar-min.js"></script>

<link rel="stylesheet" type="text/css" href="http://76.12.181.86/CFIDE/scripts/ajax/resources/yui/yui.css" />

<link rel="stylesheet" type="text/css" href="http://76.12.181.86/CFIDE/scripts/ajax/resources/cf/cf.css" />

<script type="text/javascript" src="http://76.12.181.86/CFIDE/scripts/cfform.js"></script>

<script type="text/javascript" src="http://76.12.181.86/CFIDE/scripts/masks.js"></script>

 

<title>Center on Education Policy, national independent advocate for public education and for more effective public schools</title>

 

<meta http-equiv="expires" content="0" />

<meta http-equiv="cache-control" content="no-cache" />

<meta http-equiv="pragma" content="no-cache" />

<meta http-equiv="robots" content="all" /> 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 

<link rel="stylesheet" media="screen, projection" type="text/css" href="/cep/cep_admin.css" />

<link rel="stylesheet" media="screen, projection" type="text/css" href="/cep/common.css" />

 

 

 

<meta http-equiv="description" content="The Center on Education Policy is a national, independent advocate for public education and for more effective public schools. The Center helps Americans better understand the role of public education in a democracy and the need to improve the academic quality of public schools. We do not represent any special interests. Instead, we try to help citizens make sense of the conflicting opinions and perceptions about public education and create the conditions that will lead to better public schools. Center on Education Policy, national independent advocate for public education and for more effective public schools" />

 

<meta http-equiv="keywords" content="Center on Education Policy, national independent advocate, public education, effective public schools" />

 

 

 

<script type="text/javascript"> 

 

/***********************************************

* Show Hint script- © Dynamic Drive (www.dynamicdrive.com)

* This notice MUST stay intact for legal use

* Visit http://www.dynamicdrive.com/ for this script and 100s more.

***********************************************/

		

var horizontal_offset="9px" //horizontal offset of hint box from anchor link

 

/////No further editting needed

 

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.

var ie=document.all

var ns6=document.getElementById&&!document.all

 

function getposOffset(what, offsettype){

var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;

var parentEl=what.offsetParent;

while (parentEl!=null){

totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;

parentEl=parentEl.offsetParent;

}

return totaloffset;

}

 

function iecompattest(){

return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body

}

 

function clearbrowseredge(obj, whichedge){

var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1

if (whichedge=="rightedge"){

var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40

dropmenuobj.contentmeasure=dropmenuobj.offsetWidth

if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)

edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)

}

else{

var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18

dropmenuobj.contentmeasure=dropmenuobj.offsetHeight

if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)

edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight

}

return edgeoffset

}

 

function showhint(menucontents, obj, e, tipwidth){

if ((ie||ns6) && document.getElementById("hintbox")){

dropmenuobj=document.getElementById("hintbox")

dropmenuobj.innerHTML=menucontents

dropmenuobj.style.left=dropmenuobj.style.top=-500

if (tipwidth!=""){

dropmenuobj.widthobj=dropmenuobj.style

dropmenuobj.widthobj.width=tipwidth

}

dropmenuobj.x=getposOffset(obj, "left")

dropmenuobj.y=getposOffset(obj, "top")

dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"

dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"

dropmenuobj.style.visibility="visible"

obj.onmouseout=hidetip

}

}

 

function hidetip(e){

dropmenuobj.style.visibility="hidden"

dropmenuobj.style.left="-500px"

}

 

function createhintbox(){

var divblock=document.createElement("div")

divblock.setAttribute("id", "hintbox")

document.body.appendChild(divblock)

}

 

if (window.addEventListener)

window.addEventListener("load", createhintbox, false)

else if (window.attachEvent)

window.attachEvent("onload", createhintbox)

else if (document.getElementById)

window.onload=createhintbox

 

</script>

 

 

 

 

<!-- all of this script, below, belongs to tinyMCE; pay no attention -->

 

<script language="javascript" type="text/javascript" src="/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>

 

 

<script type="text/javascript"> 

 

tinyMCE.init({

// General options

mode : "textareas",

theme : "advanced",

convert_urls : "false",

plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

 

 

// Theme options

theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",

theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",

theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",

theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",

theme_advanced_toolbar_location : "top",

theme_advanced_toolbar_align : "left",

theme_advanced_statusbar_location : "bottom",

theme_advanced_resizing : true,

 

 

// Example content CSS (should be your site CSS)

 

content_css : "css/example.css",

 

// Drop lists for link/image/media/template dialogs

 

template_external_list_url : "js/template_list.js",

external_link_list_url : "js/link_list.js",

external_image_list_url : "js/image_list.js",

media_external_list_url : "js/media_list.js",

 

// Replace values for the template plugin

 

template_replace_values : {

username : "Some User",

staffid : "991234"

}

 

});

</script>

<!-- /tinyMCE -->

 

<script type="text/javascript"> 

	if (window.ColdFusion) ColdFusion.required['DocumentTitle']=true;

</script>

 

<script type="text/javascript"> 

	if (window.ColdFusion) ColdFusion.required['DocumentAuthor']=true;

</script>

 

<script type="text/javascript"> 

	ColdFusion.Ajax.importTag('CFINPUT-DATEFIELD');

</script>

 

		<script type="text/javascript">

			var _cf_DATEFIELD_init_1282673289966=function()

			{

				ColdFusion.Calendar.setUpCalendar("DocumentPublicationDate", "MM/DD/YYYY", 0, ["S","M","T","W","T","F","S"], ["January","February","March","April","May","June","July","August","September","October","November","December"], 'CFForm_1', {month:'07', day:'15', year:'2010'});

			};ColdFusion.Event.registerOnLoad(_cf_DATEFIELD_init_1282673289966);

		</script>

		<script type="text/javascript"> 

<!--

    _CF_checkCFForm_1 = function(_CF_this)

    {

        //reset on submit

        _CF_error_exists = false;

        _CF_error_messages = new Array();

        _CF_error_fields = new Object();

        _CF_FirstErrorField = null;

 

        //form element DocumentTitle required check

        if( !_CF_hasValue(_CF_this['DocumentTitle'], "TEXT", false ) )

        {

            _CF_onError(_CF_this, "DocumentTitle", _CF_this['DocumentTitle'].value, "Document title is required! Please restrict the Document title to 100 characters or fewer.");

            _CF_error_exists = true;

        }

 

        //form element DocumentAuthor required check

        if( !_CF_hasValue(_CF_this['DocumentAuthor'], "TEXT", false ) )

        {

            _CF_onError(_CF_this, "DocumentAuthor", _CF_this['DocumentAuthor'].value, "Enter Document Author Name");

            _CF_error_exists = true;

        }

 

        //form element DocumentPublicationDate 'USDATE' validation checks

        if (!_CF_checkdate(_CF_this['DocumentPublicationDate'].value, false))

        {

            _CF_onError(_CF_this, "DocumentPublicationDate", _CF_this['DocumentPublicationDate'].value, "Publication Date must be a valid date!");

            _CF_error_exists = true;

        }

 

 

        //display error messages and return success

        if( _CF_error_exists )

        {

            if( _CF_error_messages.length > 0 )

            {

                // show alert() message

                _CF_onErrorAlert(_CF_error_messages);

                // set focus to first form error, if the field supports js focus().

                if( _CF_this[_CF_FirstErrorField].type == "text" )

                { _CF_this[_CF_FirstErrorField].focus(); }

 

            }

            return false;

        }else {

            return true;

        }

    }

//-->

</script>

</head>

 

<body>

 

 

<div id = "container">

 

<div id = "cep_header">

 

 

<!-- cep_header_left  -->

<div class="cep_header_left"><a href="/cep/admin/"><img src="/cep/img/CEP_Logo.gif" width="215" height="116" alt="Go to CEP Document Administration Page" title="Go to CEP Document Administration Page" class="border0" /></a></div>

 

<!-- /cep_header_left  -->

 

<!-- cep_header_right  -->

 <div class="cep_header_right">

 

 

 <p class="bold">

  &copy; 2010 Center on Education Policy. All rights reserved. This web site is the property of Center on Education Policy. Authorized users only may view and use this web site. If you are not authorized by Center on Education Policy to view this web site, please exit immediately.</p>

  

  

<p><a href="/cep/admin/">CEP Document Administration Page</a></p>

 

<p><a href="/cep/logout.cfm">Log Out</a></p>

 

 

 

    <!-- close cep_header_right  -->

   </div>

   

      <!-- close cep_header  -->

   </div>

   

         <!-- begin content area  -->

   <div id = "content">

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

				

				

					  

					  

  					  

				

                

                

  

				

				<form name="CFForm_1" id="CFForm_1" action="/cep/admin/insert_update.cfm?DocumentID=118" method="post" enctype="multipart/form-data" onsubmit="return _CF_checkCFForm_1(this)">

 

 

 

 

<input type="hidden" name="documentID" value="118" />

 

   

 

 

 

  

 

      <h2>Edit Document</h2>

 

  

  

  

  

 

<table class="table_admin">

 

 <tr>

  <td>

<p><strong>Document ID: 118</strong></p>

  </td>

 </tr>

 

 

 <tr>

  <td>

   <p><strong>Document Title</strong><br />

 

   <input name="DocumentTitle" id="DocumentTitle"  type="text" value="School Districts' Perspectives on the Economic Stimulus Package: Teaching Jobs Saved in 2009-10 But Teacher Layoffs Loom for Next School Year" maxlength="250"  size="100"  /></p>

  </td>

 </tr>

 <tr>

  <td>

   <p><strong>Document Type</strong>  <a href="#" class="hintanchor" onMouseover="showhint('Don\'t worry too much about document type. Specify document type \'Report\' for most CEP documents.', this, event, '200px')">[?]</a></p>

 

   <select name="DocumentType" value="#form.DocumentType#">

   			<option value="Report">Report</option>

            <option value="Policy Brief">Policy Brief</option>

            <option value="Press Release">Press Release</option>

            <option value="Article">Article</option>

            <option value="Summary">Summary</option>

            <option value="Letter">Letter</option>

            <option value="Letter">Pamphlet</option>

            <option value="Letter">Information Bulletin</option>

            <option value="Audio Transcript">Audio Transcript</option>

            <option value="Text Transcript">Text Transcript</option>

   </select>

  </td>

 </tr>

 

 

 <tr>

  <td>

   <p><strong>Document Author</strong><br />

 

   <input name="DocumentAuthor" id="DocumentAuthor"  type="text" value="Nancy Kober" maxlength="100"  size="100"  /></p>

  </td>

 </tr>

 

 

 

 

 

  <tr>

  <td>

    <p><strong>Assign this Document to CEP Topics</strong> <a href="#" class="hintanchor" onMouseover="showhint('Assign this document to a topic', this, event, '200px')">[?]</a></p>

    

    

      <p class="small">Choose at least one topic. To select more than one topic, hold the Ctrl or the Shift key (on your keyboard) and select topics with the mouse cursor.</p>

   

 

 

 

       

     

       

      

 

<select name="SelectDocumentTopics" id="SelectDocumentTopics" multiple="multiple" size="8" >

 

     <option value="0">Choose topic:</option>

    <option value="1">Congressional Testimony</option>

    <option value="2">Democracy and Public Schools</option>

    <option value="3">Dropouts</option>

    <option value="4" selected="selected">Economic Stimulus Package</option>

    <option value="5">Education and Jobs</option>

    <option value="6">Federal Education Programs</option>

    <option value="7">High School Exit Examinations</option>

    <option value="24" selected="selected">Home / What's New</option>

    <option value="8">Improving Public Schools</option>

    <option value="9">International Studies</option>

    <option value="10">No Child Left Behind</option>

    <option value="11">Public Engagement</option>

    <option value="12">Public School Facts</option>

    <option value="13">Rethinking the Federal Role in Elementary and Secondary Education</option>

    <option value="14">Special Education</option>

    <option value="15">Standards-Based Education Reform</option>

    <option value="17">State Test Score Trends Reports</option>

    <option value="16">State Testing Data</option>

    <option value="25">Student Achievement</option>

    <option value="18">Teachers</option>

    <option value="19">Testing</option>

    <option value="20">Title I</option>

    <option value="21">Violence and Crime in Schools</option>

    <option value="22">Virtual Schools</option>

    <option value="23">Vouchers</option>

</select>

 

  </td>

 </tr>

 

 

 <tr>

  <td>

   <p><strong>Document Abstract</strong><br />

   

   <textarea name="DocumentAbstract" wrap="virtual" style ="width:600px; height:250px;"><p>In the spring of 2010, CEP surveyed a nationally representative sample of school districts to learn about their fiscal situation and how the funds provided under the American Recovery and Reinvestment Act (ARRA) have impacted them over the last year. CEP found that the federal funds helped districts save or create teaching jobs and stabilize budgets, but that most districts expected to layoff teachers in the 2010-11 school year. The report also addresses districts' efforts to carryout ARRA's four reform areas, district uses of State Fiscal Stabilization Funds and supplemental Title I and IDEA funds, and problems faced by districts in implementing ARRA.</p></textarea>

   </p>

  </td>

 </tr>

 

 

 <tr>

  <td>

   <p><strong>Publication Date (use form MM/DD/YYYY; please click the calendar icon, below)</strong><br />

   <div  style="position:relative;float:left;">

	<div  style="float:left;">

		<input name="DocumentPublicationDate" id="DocumentPublicationDate"  type="datefield" value="07/15/2010" maxlength="10"  class="datefieldinput"  size="10"  />

	 </div><div  id="DocumentPublicationDateCFForm_1_cf_buttondiv" style="float:left;padding:3px;">

		

		<img id="DocumentPublicationDateCFForm_1_cf_button" src="http://76.12.181.86/CFIDE/scripts/ajax/resources/cf/images/DateChooser.png"/>

		

	 </div><div  id="DocumentPublicationDateCFForm_1_cf_container" style="display:none; position:absolute; font-size:12px;overflow:visible;float:left;z-index:9050;top:1.5em;">

		

	 </div>

 </div></p>

  </td>

 </tr>

 </table>

 

  

  

 

 

 

   

 

 

<p>Below, please see the files currently associated with Document ID <strong>118</strong>. If there are no files associated with the document, then no files will appear below. You have the option to upload a file (PDF, DOC, image file), which will associate the file with this document.</p>

 

 

 

   

 

  

 

  

   <table class="tablecontrolpanel width600px">

     <tr>

      <td><strong>File ID</strong></td>

      <td><strong>Files associated with this CEP document:</strong></td>

      <td><strong>File Link Text</strong> <a href="#" class="hintanchor" onMouseover="showhint('What link text should the user click on to open this file?', this, event, '200px')">[?]</a></td>

      <td><strong>Mark for Deletion</strong>  <a href="#" class="hintanchor" onMouseover="showhint('If you want this file to no longer associate with this document, you can mark the file for deletion; the file will be deleted from the server', this, event, '200px')">[?]</a></td>

          <td><strong>Press Release</strong>  <a href="#" class="hintanchor" onMouseover="showhint('Mark this file as a Press Release', this, event, '200px')">[?]</a></td>

         

     </tr>

     

     

     

     

     

     

	  

	 

     <input type="hidden" name="numberFiles" value="3">

          

     

        

        

      

     <tr style="background-color:#ffffff">

 

          

       <td>114</td>

 

 

 

          

       <td>Appendix_SchoolDistrictsARRAReport_071510.pdf</td>

       

 

           

        

        

          

       <td><input name="updateFileLinkText1" id="updateFileLinkText1"  type="text" value="Appendix" maxlength="100"  size="50"  />

            <input type="hidden" name="fileID1" value="114" />

       </td>

               

      

               

       <td><input type="checkbox" name="deleteFileID" value="114" class="border0" /></td>

 

     

       <td>

       

     

 

      <input type="checkbox" name="isPressRelease" class="border0" value="114" >

      

</td>

 

 

 

</tr>

 

 

    

     

 

 

     

     

     

	  

	 

     <input type="hidden" name="numberFiles" value="3">

          

     

        

      

      

     <tr style="background-color:#ebebeb">

 

          

       <td>115</td>

 

 

 

          

       <td>SchoolDistrictsARRAReport_071510.pdf</td>

       

 

           

        

        

          

       <td><input name="updateFileLinkText2" id="updateFileLinkText2"  type="text" value="Report" maxlength="100"  size="50"  />

            <input type="hidden" name="fileID2" value="115" />

       </td>

               

      

               

       <td><input type="checkbox" name="deleteFileID" value="115" class="border0" /></td>

 

     

       <td>

       

     

 

      <input type="checkbox" name="isPressRelease" class="border0" value="115" >

      

</td>

 

 

 

</tr>

 

 

    

     

 

 

     

     

     

	  

	 

     <input type="hidden" name="numberFiles" value="3">

          

     

        

        

      

     <tr style="background-color:#ffffff">

 

          

       <td>116</td>

 

 

 

          

       <td>PressRelease_SchoolDistrictsARRAReport_071510.pdf</td>

       

 

           

        

        

          

       <td><input name="updateFileLinkText3" id="updateFileLinkText3"  type="text" value="Press Release" maxlength="100"  size="50"  />

            <input type="hidden" name="fileID3" value="116" />

       </td>

               

      

               

       <td><input type="checkbox" name="deleteFileID" value="116" class="border0" /></td>

 

     

       <td>

       

     

 

      <input type="checkbox" name="isPressRelease" class="border0" value="116" >

      

</td>

 

 

 

</tr>

 

 

    

     

 

 

     

   </table>

 

  

 

<p><strong>Upload a <em>new</em> file: PDF, TEXT, DOC, DOCX, XLS, XLXS, or image files only:</strong> <a href="#" class="hintanchor" onMouseover="showhint('Browse your local computer disk to find a file to upload', this, event, '200px')">[?]</a>

 

  

  

 

<input name="FileName" id="FileName"  type="file" maxlength="255"  size="25"  class="btn"  accept="application/msexcel,application/msword,application/pdf,image/gif,image/jpeg,image/x-png"  onmouseout="this.className='btn'"  onmouseover="this.className='btn btnhov'"  />

			</p>

            

              

   <p><strong>Enter File Link Text:</strong> <a href="#" class="hintanchor" onMouseover="showhint('What link text should the user click on to open this file?', this, event, '200px')">[?]</a><br />

 

   <input name="FileLinkText" id="FileLinkText"  type="text" maxlength="100"  size="50"  /></p>

       

            

            

           

           

   <div class="align-center">

   

   

   

  

    <input name="doSave" type="submit" value="Update This Document" class="btn" onMouseOver="this.className='btn btnhov'" onMouseOut="this.className='btn'" /> 

  

  

  <span class="hintanchortext"><a href="#" class="hintanchor" onMouseover="showhint('Click the Update This Document button immediately left to apply your edits to this document', this, event, '200px')">[?]</a></span>

  

   

   

   

 

 

<hr />

 

<div class="graybox align-center width250px">

  <p>The button below deletes this document, its database record, and its associated files. Use deliberately and with caution.</p>

</div>

 

 

 

 

  <input name="doDelete" type="submit" value="Delete This Document" class="btn" onMouseOver="this.className='btn btnhov'" onMouseOut="this.className='btn'" onclick="return confirm('Are you sure you wish to delete this document? After you delete it it is gone forever.')" />

 

 

 

 

 

</div>

  

 

 

 

 

 

<input type='hidden' name='DocumentTitle_CFFORMREQUIRED' value='Document title is required! Please restrict the Document title to 100 characters or fewer.'>

<input type='hidden' name='DocumentAuthor_CFFORMREQUIRED' value='Enter Document Author Name'>

<input type='hidden' name='DocumentPublicationDate_CFFORMUSDATE' value='Publication Date must be a valid date!'>

</form>

 

 

 

 

 

 

 

<!-- END content area  -->

</div>

 

 

 

<!-- footer -->

 

<div id="footer">

 

 

 

<div class="footer-left">

 

 

 

  <p>

  &copy; 2010 Center on Education Policy. All rights reserved.

  </p>

 

 

</div>

 

 

 

 

<div class="footer-right">

 

<div class="w3cbutton3">

  <a href="http://validator.w3.org/check?uri=referer">

    <span class="w3c">W3C</span>

    XHTML 1.0

  </a>

</div>

		

<div class="w3cbutton3">

  <a href="http://jigsaw.w3.org/css-validator/check/referer">

    <span class="w3c">W3C</span>

    CSS 2.1

  </a>

</div>

 

</div>

 

 

 

 

 

 

 

<!-- end footer -->

</div>

 

 

<!--end container-->

</div>

 

 

 

 

 

 

 

 

 

 

<!-- GOOGLE Analytics -->

 

<script type="text/javascript"> 

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." :

"http://www.");

document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

</script>

<script type="text/javascript">

var pageTracker = _gat._getTracker("UA-2840437-2"); pageTracker._initData(); pageTracker._trackPageview(); </script>

 

<!-- close body -->

</body>

 

<!-- wrap it up -->

</html>

Open in new window

0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33514363

Eric,

Please do one thing for now as m getting headache.(SORY)
Just change the field of "isPressRelease" to "chkPressRelease"

try it.

m slping now.

u enjoy ur day.

bhavesh

0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33514724
Will do. Sleep well my friend. EB
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33517114
Dear Bhavesh,

I hope you slept well and that your headache has gone.

I changed the name of the isPressRelease checkbox to chkPressRelease:

   <!--- isPressRelease checkbox --->  

      <input type="checkbox" name="chkPressRelease" class="border0" value="#getFiles.fileID#" <cfif ListFind(form.isPressRelease,getFiles.fileID)>checked</cfif>>

... but the isPressRelease checkbox is still unchecked when I load the update page. =(

Rats! =)

I really appreciate the amount of time and thought you have put into this question. I am thinking I will close the question and give you the points, then open a new question. What do you think?

Eric
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33517779
My Dear Eric,

Yes I slept wwell,thanks......

I asked you to change name,but it means u need to change everywhere.


 <input type="checkbox" name="chkPressRelease" class="border0" value="#getFiles.fileID#" form.isPressRelease,getFiles.fileID)>checked>

please change all the variable named isPressRelease to chkPressRelease
along with cfparam.


You want to accept the solution?
why why why???

M i make u bored or what =)

Poiints is secondary, first soultion is imp.....

I dont mind to continue here.....

BTW if u dont mind may i know ur age?

-Bhavesh
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33522426
Good morning, Bhavesh,

Good to hear from you.

I went ahead and and changed all instances of isPressRelease to chkPressRelease. I attach below the results of the cfdump.

I am guessing you have a next step in mind. =)

I am definitely not bored, and as ever I am very grateful for your help.

As for my age, I am 32.

I am looking forward to whatever solution you have in mind. =) I hope you are well.

Eric



struct 

CHKPRESSRELEASE 0  

DATERECORDMODIFIED 2010-08-24 20:11:33.387  

DOCUMENTABSTRACT <p>In the spring of 2010, CEP surveyed a nationally representative sample of school districts to learn about their fiscal situation and how the funds provided under the American Recovery and Reinvestment Act (ARRA) have impacted them over the last year. CEP found that the federal funds helped districts save or create teaching jobs and stabilize budgets, but that most districts expected to layoff teachers in the 2010-11 school year. The report also addresses districts' efforts to carryout ARRA's four reform areas, district uses of State Fiscal Stabilization Funds and supplemental Title I and IDEA funds, and problems faced by districts in implementing ARRA.</p>  

DOCUMENTAUTHOR Nancy Kober  

DOCUMENTID 118  

DOCUMENTPUBLICATIONDATE 2010-07-15 00:00:00.0  

DOCUMENTTITLE School Districts' Perspectives on the Economic Stimulus Package: Teaching Jobs Saved in 2009-10 But Teacher Layoffs Loom for Next School Year  

DOCUMENTTYPE Report  

FILEID [empty string]  

NUMBERFILES [empty string]  

SELECTDOCUMENTTOPICS 4,24  

SSMA_TIMESTAMP 2010-08-19 02:01:55.73

Open in new window

0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33522811
Eric,

Good Morning.

Good to see u.
i was waiting for u from long.
Was planning to give a missed call ;-)

Frankly speaking,i dont have next step in mind.

Its very surprising that your query is getting updated properly......(I'm having really very big doubt)
Why - Because if ur checkbox value is 0 then how can your query getting updated.
Just now i got one more point for debugging.

<!---- query to set table tbl_CEP_Files, column isPressRelease to 1 ---->
                <cfquery name="qry_updateisPressRelease" datasource="#ds#">
                         UPDATE tbl_CEP_Files
                       SET isPressRelease = 1
                    WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.isPressRelease)#" list="yes">)
                  </cfquery>

thats ur query.
now above that just print

<pre>

       			UPDATE tbl_CEP_Files

           		SET isPressRelease = 1

        		WHERE FileID IN (#val(form.chkPressRelease)#)



</pre>

Open in new window

0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33522844

I will b in office for more 20 to 30 minutes.

if u wish we chat on gmail after 2.30 hours

my id is bhaveshj.shah at gmail dot com

so its gud for us that we can solve very quickly.[THIS WILL NOT BE OFFICIAL CHATTING, I MEAN NO FEES,ITS JUST SOLVING PROBLEM QUICKLY]
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33523927
Dear Brichsoft,

I will set up the <PRE> tags in a little while. Sorry -- I got pulled into another task. More soon. Hope you are well. Eric
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33526296
>>.Why - Because if ur checkbox value is 0 then how can your query getting updated.

This makes sense. But, when I submit the update form, the value of the isPressRelease column in the database table changes from 0 to 1, or from 1 to 0, depending whether or not the checkbox is checked. So when the form processes, a change does happen in the database.

Next, I added the PRE tags per your suggestion. I put this (see code below).

I process the form and, as you probably expected, I get this error:

 UPDATE tbl_CEP_Files
                        SET isPressRelease = 1
                        WHERE FileID IN (#val(form.chkPressRelease)#)
 
The web site you are accessing has experienced an unexpected error.
Please contact the website administrator.

The following information is meant for the website developer for debugging purposes.  

Error Occurred While Processing Request  
Error Executing Database Query.  
[Macromedia][SQLServer JDBC Driver][SQLServer]Invalid column name 'chkPressRelease'.  
 
The error occurred in C:\websites\ebwebwork.com\cep\admin\insert_update_test.cfm: line 293
Called from C:\websites\ebwebwork.com\cep\admin\insert_update_test.cfm: line 54
Called from C:\websites\ebwebwork.com\cep\admin\insert_update_test.cfm: line 40
Called from C:\websites\ebwebwork.com\cep\admin\insert_update_test.cfm: line 1
Called from C:\websites\ebwebwork.com\cep\admin\insert_update_test.cfm: line 293
Called from C:\websites\ebwebwork.com\cep\admin\insert_update_test.cfm: line 54
Called from C:\websites\ebwebwork.com\cep\admin\insert_update_test.cfm: line 40
Called from C:\websites\ebwebwork.com\cep\admin\insert_update_test.cfm: line 1
 
291 :                          UPDATE tbl_CEP_Files
292 :                        SET chkPressRelease = 0
293 :                     WHERE DocumentID=<cfqueryparam value="#val(form.DocumentID)#" cfsqltype="cf_sql_integer">
294 :                       AND isDeleted = 0
295 :                   </cfquery>

 
Does this error elucidate any part of this problem?

Thank you again.

Eric
<!--- SET OR UNSET A FILE TO chkPressRelease --->

      <!--- this query must be placed within the Save Action --->

 

    	   <!--- begin CFELSEIF isDefined(form.chkPressRelease) --->

		 <cfelseif isDefined("form.chkPressRelease")>

         

         <pre> 

                        UPDATE tbl_CEP_Files 

                        SET isPressRelease = 1 

                        WHERE FileID IN (#val(form.chkPressRelease)#) 

 

		</pre>

   

   <!----query to reset table tbl_CEP_Files, column chkPressRelease to 0 ---->

 			<cfquery name="qry_updateisPressRelease" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET chkPressRelease = 0

        		WHERE DocumentID=<cfqueryparam value="#val(form.DocumentID)#" cfsqltype="cf_sql_integer"> 

    			AND isDeleted = 0

      		</cfquery>



	<!---- query to set table tbl_CEP_Files, column chkPressRelease to 1 ---->

      	    <cfquery name="qry_updateisPressRelease" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET chkPressRelease = 1

        		WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.chkPressRelease)#" list="yes">)

      		</cfquery>

Open in new window

0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33527773

Hi........

hope ur days goes well.
1stly use cfoutput b4 pre tag

<cfoutput>
 UPDATE tbl_CEP_Files
                        SET isPressRelease = 1
                        WHERE FileID IN (#val(form.chkPressRelease)#)
 </cfoutput>

2ndly u no need to replace database field with chkPressRelease.
so change back to original.
i mean in query field werever u use chkPressRelease use ur old one.
i.e.isPressRelease

<cfquery name="qry_updateisPressRelease" datasource="#ds#">
                        UPDATE tbl_CEP_Files
                        SET isPressRelease= 1
                        WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.chkPressRelease)#" list="yes">)
                </cfquery>

0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33528838
Dear Brichsoft,

Is the code, below, what you had in mind?

That code does process correctly. I mean, the form submits without an error. However, the output from the PRE tag is no longer visible? Is this what you had in mind?

Sorry if I am being dense. Thank you again. I will catch a few hours of sleep and be back at my computer soon. Take care.

Eric
<!--- SET OR UNSET A FILE TO chkPressRelease --->

      <!--- this query must be placed within the Save Action --->

 

    	   <!--- begin CFELSEIF isDefined(form.chkPressRelease) --->

		 <cfelseif isDefined("form.chkPressRelease")>

         <cfoutput>

         <pre> 

                        UPDATE tbl_CEP_Files 

                        SET isPressRelease = 1 

                        WHERE FileID IN (#val(form.chkPressRelease)#) 

 

		</pre>

        </cfoutput>

   

   <!----query to reset table tbl_CEP_Files, column chkPressRelease to 0 ---->

 			<cfquery name="qry_updateisPressRelease" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET isPressRelease = 0

        		WHERE DocumentID=<cfqueryparam value="#val(form.DocumentID)#" cfsqltype="cf_sql_integer"> 

    			AND isDeleted = 0

      		</cfquery>



	<!---- query to set table tbl_CEP_Files, column chkPressRelease to 1 ---->

      	    <cfquery name="qry_updateisPressRelease" datasource="#ds#">

       			UPDATE tbl_CEP_Files

           		SET isPressRelease = 1

        		WHERE FileID IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#val(form.chkPressRelease)#" list="yes">)

      		</cfquery>

Open in new window

0
 
LVL 52

Accepted Solution

by:
_agx_ earned 250 total points
ID: 33529097
Hi Eric.

Sorry I've been a bit busy, and haven't caught up on the whole thread. Hopefully if I'm repeating things.  But here goes ..

Updating a boolean setting, via a checkbox, is tricky because you have to know the state of _all_ of the checkboxes.  A bit of a challenge, as checkboxes don't pass any value when they're NOT checked.  But since all of the files belong to the same parent #documentID#, you can use a little reverse  logic.   Use #form.documentID# to identify _all_ files for the current document. Then use #form.isPressRelease# to _exclude_ the ones that WERE checked.  That leaves you with files that were NOT checked.  Just apply that logic to to your UPDATE queries. Make sense?

So give all of the checkboxes the same name. Be sure to use the #fileID# as the box value:

      <cfloop query="getFiles">
               ...
             <input type="checkbox" name="isPressRelease" value="#fileID#"
                         <cfif getFiles.isPressRelease>checked</cfif>>
      </cfloop>

When the form is submitted, run one query to update the UNCHECKED files

      <!--- ensure the field exists --->
      <cfparam name="form.isPressRelease" default="" >
        ...

      <!--- handle any UNCHECKED files --->
      <cfquery name="uncheckedFiles" datasource="#yourDSN#">
            UPDATE      tbl_CEP_files
            SET     isPressRelease = 0
            WHERE      documentID = <cfqueryparam value="#form.documentID#" cfsqltype="cf_sql_integer">
            <cfif listLen(form.isPressRelease)>
            AND            fileID NOT IN
                        (
                              <cfqueryparam value="#form.isPressRelease#" list="true" cfsqltype="cf_sql_integer">
                        )
            </cfif>
      </cfquery>


Then another to update the CHECKED files.

      <!--- handle CHECKED files...--->
      <cfif listLen(form.isPressRelease)>
            <cfquery name="checkedFiles" datasource="#yourDSN#">
            UPDATE      tbl_CEP_files
            SET     isPressRelease = 1
            WHERE      fileID IN
                        (
                              <cfqueryparam value="#form.isPressRelease#" list="true" cfsqltype="cf_sql_integer">
                        )
            </cfquery>
      </cfif>
      

That's it.  You'll probably want to wrap the real queries in a cftransaction. But that's the basic idea.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 33529103
>> Hopefully if I'm repeating things.

Correction:  Hopefully I'm NOT repeating things ;-)
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33529112
_agx_ -- thank you! I will give this a try when I am more awake! =) EB
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33532424
Hey Mr.Agx.....

Thanks for ur comment.
And your idea is also is fabulous.

Eric - now u surely get ur answer.


But Agx - can u assue whats the problem having it.I mean checkbox is defined so query is updating but its not getting checked.....else my code is also right ;-)

Eric - hope your day was going good.

Actually, I wish to share somethng gr8 with EE Guys.....(Sory m going out of topic)

Was got stuck up in work from morning so couldnot reply it here.But just hour before I m through and also I achieve my very first Master Certification in SQL SERVER ZONE.....

so just want to share.....

Hope your both enjoying ur times....I'm really very happy to achieve this...

I cnt stop my happiness.................
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33532439

Sory for my personl comments.......
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33534396
Hello friends -- I am still studying the code above, implementing it, and adjusting. This is educational. I will post a result here soon. Peace! And of course my thanks. EB
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33535207
Brichsoft -- Master Certification in SQL SERVER ZONE..... Congratulations! I have really benefited from your expertise.

>>>>checkboxes don't pass any value when they're NOT checked.

This fact has caused much heartache.

>>>> Use #form.documentID# to identify _all_ files for the current document.

Check.

>>use #form.isPressRelease# to _exclude_ the ones that WERE checked.  That leaves you with files that were NOT checked.

Yes! That is a great idea!

.... and ... it's working. I enclosed both queries in CFTRANSACTION. I am running a few more tests to make sure I did not break anything. =) More soon.
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 33536234
It's working very well.

There is one more problem with the application -- but I do not think it involves the changes we have made today. I am working to resolve that problem on my own; I might ask later for assistance if I do not get it.

_agx_ and Brichsoft, I will split the points between you, if that is OK. I am extremely grateful. =) In fact I have been cheering silently in my chair at my desk as I test this new, working function.

Eric
0
 
LVL 3

Author Closing Comment

by:Eric Bourland
ID: 33536268
Congratulations Brichsoft on achieving Master Certification in the SQL Server Zone! Many thanks, as always, to Brichsoft and_agx_ for their help. Peace! Eric B
0
 
LVL 52

Expert Comment

by:_agx_
ID: 33536566
Sorry for the delay guys.  Meetings, meetings, and more meetings ;-)

Congratulations @Brichsoft !  It feels good to have helped and earned that first badge. Keep up the good work :)



0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33543113

Thanks guys for your wishes.

Sory Eric, I take ur much time.

Eric - may i have ur email id?
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now