Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 745
  • Last Modified:

Date picker during for date field in cfupdate edit

The code below is apart of a cfupdate.

1. Query results are displayed on a webpage.
2. Edit buttons are displayed next to each record.
3. Edit button is clicked for a specific data row to be edited.
4. User can change text fields, drop down selections but not date fields.

How can I add a small date picker to a date field to allow users to change a date if need me during an edit?

Thanks in advance.
<CFOUTPUT>

<form action="mysrs.cfm?user_name=#url.user_name#&From=DoEdit&ID=#Ticket_num#" method="post">

<tr bgcolor="iif(currentrow MOD 1,DE('ff6600'))">
<td><font size=2>#Ticket_num#</font></td>

<td><font size=2>#Title#
<select name="Title">
<cfloop query="dropdownvalues">
<option>#dropdownvalues.title_name#</option>
</cfloop>
</select></font></td>

<td><font size=2>#Network#
<select name="Network">
<cfloop query="ddvsnetwork">
<option>#ddvsnetwork.Network#</option>
</cfloop>
</select></font></td>

<td><font size=2>#Assigned_To#
<select name="Assigned_to">
<cfloop query="at">
<option>#at.A_to#</option>
</cfloop>
</select></font></td>

<td><font size=2>#Last_Name#</font></td>
<td><font size=2>#First_Name#</font></td>
<td><font size=2><input type="text" name="Opened_Date" size="10" value="#DateFormat(Opened_Date,'mm/dd/yyyy')#"></font></td>
<td><font size=2><input type="text" name="Closed_Date" size="10" value="#DateFormat(Closed_Date,'mm/dd/yyyy')#"></font></td>
<td><font size=2><input type="text" name="Status" size="10" value="#Status#"></font></td>
<td><font size=2><input type="text" name="Priority" size="10" value="#Priority#"></font></td>
<td><font size=2><input type="text" name="Description" size="30" value="#Description#"></font></td>
<td><font size=2><input type="text" name="Date_Completed" size="10" value="#Date_Completed#"></font></td>
<td><font size=2><input type="text" name="Comments" size="25" value="#Comments#"></font></td>
</tr>

</CFOUTPUT>

Open in new window

0
jslaught
Asked:
jslaught
  • 12
  • 7
  • 2
1 Solution
 
_agx_Commented:
Assuming you're running CF8+ you can use a <cfinput> field.  It's just like a plain html <input> with lots of extra features ;-)  The one catch is it must be nested inside a <cfform>.  So be sure to change your <form> to <cfform>

ie

<cfform action="mysrs.cfm?user_name=#url.user_name#&From=DoEdit&ID=#Ticket_num#" method="post">
... other fields ....
      <cfinput type="datefield" name="Opened_Date" mask="mm/dd/yyyy" value="#Opened_Date#">
... other fields ....
</cfform>

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7f51.html
0
 
jslaughtAuthor Commented:
FYI... I am running CF9.
I Incorporated your suggestions above and recieved the following error message:
2011-04-17 00:00:00/0 is an invalid date or time string.

So I edited the Opened Date field in the table row to the code example below:

I get no errors but the cfupdate no longer works.







<cfform action="mysrs.cfm?user_name=#url.user_name#&From=DoEdit&ID=#Ticket_num#" method="post">
... other fields ....
      <cfinput type="datefield" name="Opened_Date" mask="mm/dd/yyyy" value="#DateFormat(Opened_Date, mm/dd/yyyy')#">
... other fields ....
</cfform>

Open in new window

0
 
_agx_Commented:
Looks like you're missing an opening quote around the date mask

ie
#DateFormat(Opened_Date, **quote missing here** mm/dd/yyyy')#


With cfinput datefield, the value has to be something CF can translate into a date/time object.  "2011-04-17 00:00:00/0" value looks odd ... Not like a regular date/time value.  What is the data type of your "Opened_date" column?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
jslaughtAuthor Commented:
The missing quote that you mentioned above is actually there in my code. I guess I missed putting it in when I placed it on here. Same result result though... cfupdate doesn't perform the edit.

datatype of Opened_date column is date/time in microsoft access.
0
 
_agx_Commented:
I'm not sure what you mean by "doesn't perform the edit".  Are you saying it updates all other column values *except* that one?

Let me find an Access machine and try a quick test myself.
0
 
_agx_Commented:
Oh wait ... you're not literally using this code right?  

<cfform action="mysrs.cfm?user_name=#url.user_name#&From=DoEdit&ID=#Ticket_num#" method="post">
... other fields ....
      <cfinput type="datefield" name="Opened_Date" mask="mm/dd/yyyy" value="#DateFormat(Opened_Date, mm/dd/yyyy')#">
... other fields ....
</cfform>

Open in new window


That's just an example to outline the changes needed.  
 
ie
a) replace your <form> tags with <cfform>  and
b) replace the <input name="Opened_Date" ...> field with
      <cfinput type="datefield" name="Opened_Date"
          mask="mm/dd/yyyy" value="#DateFormat(Opened_Date, mm/dd/yyyy')#">

0
 
jslaughtAuthor Commented:
when I say edit  i mean the cfupdate

when I click the "udpate" button after changing the date field it doesn't update any of the column values.

Note: I did not literally use your example code. I knew what to replace and the update is still not happening.

0
 
_agx_Commented:
Ok, just want to be sure we're both on the same page.

when I click the "udpate" button after changing the date field it doesn't update any of the column values.


Just switching to a cfform shouldn't affect the cfupdate unless something else was changed (like url variables, field names, etc). Try adding some debugging code before your cfupdate section. After you click the "update" button what results do you see?

<!--- show the url and form variables --->
<cfdump var="#URL#" label="URL Variables are:">
<cfdump var="#FORM#" label="FORM Variables are:">


<!-- If URL.From is defined and equals DoEdit, then update the table -->
<CFIF IsDefined("URL.From")>
      <CFIF #URL.From# IS "DoEdit">
          <CFUPDATE DATASOURCE="SSPSRs" TABLENAME="Issues">
      </CFIF>
</CFIF>

.... rest of code ...



0
 
_agx_Commented:
I tested it and it works fine. So it's likely something else in the code was changed besides that one <input> and <form> tags.


As an aside, there's probably some excess code in the original form.  Once you get this issue fixed you could probably simplify the form down to something like this:

<!--- your dsn ... --->
<cfset yourDSN = "SSPSRs">

<!--- ensure variables always exist. default to invalid values --->
<cfparam name="url.user_name" default="">
<cfparam name="URL.From" default="">
<cfparam name="URL.ID"  default="-1">
<cfset wasUpdated = false>

<!-- If URL.From is defined and equals DoEdit, then update the table -->
<CFIF URL.From eq "DoEdit">
    <CFUPDATE DATASOURCE="#yourDSN#" TABLENAME="Issues">
    <!--- clear the id to mark the update complete --->
    <cfset URL.id = -1>
    <cfset wasUpdated = true>
</CFIF>

<!-- The below code selects all data from the table -->
<CFQUERY NAME="all" DATASOURCE="#yourDSN#">
    SELECT    * 
    FROM    Issues 
    WHERE    user_name = <cfqueryparam value="#url.user_name#" cfsqltype="cf_sql_varchar">
    <!--- if a ticket number exists, pull the information for editing --->
    <cfif url.id gt 0>
        AND    Ticket_Num = <cfqueryparam value="#url.id#" cfsqltype="cf_sql_integer">
    </cfif>
</CFQUERY>

<html>
<head></head>
<body>
	<!--- headers --->
    <cfoutput><a href="trackertabs.cfm?user_name=#url.user_name#&tab=2"></cfoutput>    
    <img src="http://127.0.0.1:8500/TicketTracking/pics/imagesCA6WFWX0.jpg" width=50 height=50 alt="go back to service tab" border="0" /></a><br>
    <center>
        <font size=6 font face="Copperplate Gothic Ligth">My Service Requests (All)</font><br>
    </center>

    <!-- If DoUpdate has been run a short note is given -->
    <CFIF wasUpdated>
        <p><b>Thanks for your update!</b>
    </CFIF>
    
	<!--- table headers --->
    <table border='0' width='100%' align='center' summary='script output'>
    <tr bgcolor="#d3d3d3">
        <th bgcolor="#d3d3d3"><font size=2><b>Service<br> Request #</b></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Request</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Network</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Assigned To</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Customer</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Opened Date</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Closed Date</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Status</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Priority</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Description</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Date Completed</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Comments</strong></font></th>
        <th></th>
    </tr>
    <!--- We are editing a single record .... --->
    <CFIF URL.ID IS all.Ticket_Num>
        <CFOUTPUT query="all">
            <cfform action="mysrs.cfm?user_name=#url.user_name#&From=DoEdit&ID=#Ticket_num#" method="post">
                <tr bgcolor="iif(currentrow MOD 1,DE('123456'))">
                <td><font size=2>#Ticket_num#</font></td>
                <td><font size=2><input type="text" name="Title" size="25" value="#Title#"></font></td>
                <td><font size=2><input type="text" name="Network" size="15" value="#Network#"></font></td>
                <td><font size=2><input type="text" name="Assigned_To" size="25" value="#Assigned_To#"></font></td>
                <td><font size=2><input type="text" name="Customer" size="25" value="#Customer#"></font></td>
                <td><font size=2><cfinput type="datefield" name="Opened_Date" size="6" width="100" mask="mm/dd/yyyy" value="#DateFormat(Opened_Date,'mm/dd/yyyy')#"></font></td>
                <td><font size=2><input type="text" name="Closed_Date" size="10" value="#DateFormat(Closed_Date,'mm/dd/yyyy')#"></font></td>
                <td><font size=2><input type="text" name="Status" size="10" value="#Status#"></font></td>
                <td><font size=2><input type="text" name="Priority" size="10" value="#Priority#"></font></td>
                <td><font size=2><input type="text" name="Description" size="30" value="#Description#"></font></td>
                <td><font size=2><input type="text" name="Date_Completed" size="10" value="#Date_Completed#"></font></td>
                <td><font size=2><input type="text" name="Comments" size="25" value="#Comments#"></font></td>
                </tr>
                <tr><td colspan="3">
                    <cfinput type="hidden" name="Ticket_num" value="#URL.ID#"><br><br><br>
                    <input type="submit">
                    </td>
                </tr>    
            </cfform>
        </CFOUTPUT>

    <!--- Otherwise we simply output all data --->
    <CFELSE>    
        <CFOUTPUT query="all">
            <tr bgcolor="###iif(currentrow MOD 2,DE('ffffff'),DE('ffff66'))#">
            <td><font size=2>#Ticket_num#</font></td>
            <td><font size=2>#Title#</font></td>
            <td><font size=2>#Network#</font></td>
            <td><font size=2>#Assigned_To#</font></td>
            <td><font size=2>#Customer#</font></td>
            <td><font size=2>#DateFormat(Opened_Date,'mm/dd/yyyy')#</font></td>
            <td><font size=2>#DateFormat(Closed_Date,'mm/dd/yyyy')#</font></td>
            <td><font size=2>#Status#</font></td>
            <td><font size=2>#Priority#</font></td>
            <td><font size=2>#Description#</font></td>
            <td><font size=2>#Date_Completed#</font></td>
            <td><font size=2>#Comments#</font></td>
            <!-- This is where the Edit button and form is created -->
            <td>
            <form action="mysrs.cfm?user_name=#url.user_name#&From=Edit&ID=#Ticket_num#" method="post">
                <input type="submit" value="Edit">
            </form>
            </td>
        </tr>
        </CFOUTPUT>
    </CFIF>
</table>
</body>
</html>

Open in new window

0
 
jslaughtAuthor Commented:
the way you simplified the code above inspired me to go through all my coldfusion webpages and make them cleaner.

Your simplified code above allowed my cfupdate to work properly until today. Today for some reason... anytime I do an update... the cfupdate code overwrites the original values from the original record with the first values from the drop down boxes. I can't figure out why all of an sudden it started to do that. I didn't really change anything. Just added the code for the other dropdown boxes for the cfupdate. i can reshow you my code if you like.
0
 
_agx_Commented:
I don't see any way that could happen. Are you sure you're selecting something from the lists?

0
 
_agx_Commented:
Also, remember preselecting list items doesn't happen automatically with html <select> lists. You have to do that yourself like shown in your other thread.  

<select name="dropdown">
    <cfouput query="dropdownvalues">
        <option value="#dropdownvalues.itemID#" <cfif all.itemID eq dropdownvalues.itemID>selected="selected"</cfif>>#dropdownvalues.itemDescription#</option>
    </cfoutput>
</select>

OR you could use a <cfselect> along with it's "selected" attribute instead.
0
 
cfEngineersCommented:
Just a thought, but perhaps cfide is not mapped correctly?

Test this my adding /cfide/administrator to your root url example:http://mydomain.com/cfide/administrator

If you get to the CF admin then your cfide is mapped properly.

If not, this can effect the cfform and other things as well.
0
 
jslaughtAuthor Commented:
To agx: below is the code that i'm trying to get the dropdowns to work properly. This is apart of what you suggested to me in some of the above threads. Here is a step by step of what is happening.

1. I have a webpage that displays results from a cfquery. (successful)
2. Beside each row from the displayed results is a edit button (per the cfupdate) in the code. (successful)
3. When a edit button is clicked the same webpage is refreshed with the specific row highlighted for editing.
4. The orginal values are displayed (whether text fields or dropdown fields).
5. The fields with dropdown lists are displayed as apart of the edit/update.
6. The dropdown lists are populated with the appropriate values ready to be selected if needed in an edit.
7. If no new values are selected in a drop down list then the original value should stay the same when the update button is selected to rewrite the values into the database.
8. This is not happening anymore. The update is rewriting the original values with the first values listed in the dropdown box during the edit.
9. This makes my test data unstable because the original record will always change to something else.

To cfEngineers: http://mydomain.net/cfide/administrator did not work but http://127.0.0.1:8500/cfide/administrator works fine.

<!--- query to put a list of of Request names in a dropdown box --->
<cfquery name="dropdownvalues" datasource="sspsrs">
    SELECT Title_Name
    FROM IssueTitles
</cfquery>


<!--- query to put a list of of SSP Internal network names in a dropdown box --->
<cfquery name="ddvsnetwork" datasource="sspsrs">
    SELECT Network
    FROM Network
</cfquery>

<!--- query to put a list of customer last names in a dropdown box --->
<cfquery name="lns" datasource="sspsrs">
    SELECT last_name
    FROM customers order by last_name asc
</cfquery>


<!--- query to put a list of customer first names in a dropdown box --->
<cfquery name="fns" datasource="sspsrs">
    SELECT first_name
    FROM customers order by first_name asc
</cfquery> 

<!--- your dsn ... --->
<cfset yourDSN = "SSPSRs">

<!--- ensure variables always exist. default to invalid values --->
<cfparam name="url.user_name" default="">
<cfparam name="URL.From" default="">
<cfparam name="URL.ID"  default="-1">
<cfset wasUpdated = false>

<!-- If URL.From is defined and equals DoEdit, then update the table -->
<CFIF URL.From eq "DoEdit">
    <CFUPDATE DATASOURCE="#yourDSN#" TABLENAME="Issues">
    <!--- clear the id to mark the update complete --->
    <cfset URL.id = -1>
    <cfset wasUpdated = true>
</CFIF>

<!-- The below code selects all data from the table -->
<CFQUERY NAME="all" DATASOURCE="#yourDSN#">
    SELECT    * 
    FROM    Issues 
    WHERE    user_name = <cfqueryparam value="#url.user_name#" cfsqltype="cf_sql_varchar">
    <!--- if a ticket number exists, pull the information for editing --->
    <cfif url.id gt 0>
        AND    Ticket_Num = <cfqueryparam value="#url.id#" cfsqltype="cf_sql_integer">
    </cfif>
</CFQUERY>

<html>
<head></head>
<body>
	<!--- headers --->
    <cfoutput><a href="trackertabs.cfm?user_name=#url.user_name#&tab=2"></cfoutput>    
    <img src="http://127.0.0.1:8500/TicketTracking/pics/imagesCA6WFWX0.jpg" width=50 height=50 alt="go back to service tab" border="0" /></a><br>
    <center>
        <font size=6 font face="Copperplate Gothic Ligth">My Service Requests (All)</font><br>
        <font size=2><i>Resolved tickets cannot be edited</i></font>
    </center>

    <!-- If DoUpdate has been run a short note is given -->
    <CFIF wasUpdated>
        <p><b>Thanks for your update!</b>
    </CFIF>
    
	<!--- table headers --->
    <table border='0' width='100%' align='center' summary='script output'>
    <tr bgcolor="#d3d3d3">
        <th bgcolor="#d3d3d3"><font size=2><b>Service<br> Request #</b></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Request</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Network</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Assigned To</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Last Name</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>First Name</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Opened &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Date</strong></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Status</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Priority</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Description</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Date Completed</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Comments</strong></font></th>
        <th></th>
    </tr>
    <!--- We are editing a single record .... --->
    <CFIF URL.ID IS all.Ticket_Num>
        <CFOUTPUT query="all">
            <cfform action="mysrs.cfm?user_name=#url.user_name#&From=DoEdit&ID=#Ticket_num#" method="post">
                <tr bgcolor="iif(currentrow MOD 1,DE('123456'))">
                <td><font size=2>#Ticket_num#</font></td>
                
		<td><font size=2>#Title#
		<select name="Title">
		<cfloop query="dropdownvalues">
		<option>#dropdownvalues.title_name#</option>
		</cfloop>
		</select></font></td>


                <td><font size=2>#Network#</font></td>
		<td><font size=2>#Assigned_To#</font></td>
		<td><font size=2>#last_name#</font></td>
		 <td><font size=2>#first_name#</font></td>
		
		<td><font size=2>#Network#
		<select name="Network">
		<cfloop query="ddvsnetwork">
		<option>#ddvsnetwork.Network#</option>
		</cfloop>
		</select></font></td>
		<td><font size=2>#Assigned_To#</font></td>
		                              
                <td><font size=2>#last_name#
		<select name="last_name">
		<cfloop query="lns">
		<option>#lns.last_name#</option>
		</cfloop>
		</select></font></td>

                <td><font size=2>#first_name#
		<select name="first_name">
		<cfloop query="fns">
		<option>#fns.first_name#</option>
		</cfloop>
		</select></font></td>

                <td><font size=2><cfinput type="datefield" name="Opened_Date" size="10" width="100" mask="mm/dd/yyyy" value="#DateFormat(Opened_Date,'mm/dd/yyyy')#"></font></td>
                <td><font size=2><input type="text" name="Status" size="10" value="#Status#"></font></td>
                <td><font size=2><input type="text" name="Priority" size="10" value="#Priority#"></font></td>
                <td><font size=2><input type="text" name="Description" size="30" value="#Description#"></font></td>
                <td><font size=2><input type="text" name="Date_Completed" size="10" value="#Date_Completed#"></font></td>
                <td><font size=2><input type="text" name="Comments" size="25" value="#Comments#"></font></td>
                

                </tr>
                <tr><td colspan="3">
                    <cfinput type="hidden" name="Ticket_num" value="#URL.ID#"><br><br><br>
                    <input type="submit">
                    </td>
                </tr>    
            </cfform>
        </CFOUTPUT>

    <!--- Otherwise we simply output all data --->
    <CFELSE>    
        <CFOUTPUT query="all">
            <tr bgcolor="###iif(currentrow MOD 2,DE('ffffff'),DE('ffcc66'))#">
            <td><font size=2>#Ticket_num#</font></td>
            <td><font size=2>#Title#</font></td>
            <td><font size=2>#Network#</font></td>
            <td><font size=2>#Assigned_To#</font></td>
            <td><font size=2>#Last_Name#</font></td>
            <td><font size=2>#First_Name#</font></td>
            <td><font size=2>#DateFormat(Opened_Date,'mm/dd/yyyy')#</font></td>
            <td><font size=2>#Status#</font></td>
            <td><font size=2>#Priority#</font></td>
            <td><font size=2>#Description#</font></td>
            <td><font size=2>#Date_Completed#</font></td>
            <td><font size=2>#Comments#</font></td>
            <!-- This is where the Edit button and form is created -->
            <td>
	<CFIF #status# is 'Active'>
            <form action="mysrs.cfm?user_name=#url.user_name#&From=Edit&ID=#Ticket_num#" method="post">
                <input type="submit" value="Edit">
            </form>
	</cfif>
            </td>
        </tr>
        </CFOUTPUT>
    </CFIF>
</table>
</body>
</html>

Open in new window

0
 
cfEngineersCommented:
So you are only hosting this locally on your machine at the moment?

If thats the case, then your cfide is mapped properly.


0
 
_agx_Commented:
I don't think you read my last response ;-) Like I said you have to preselect the values you want *explicitly*.  It doesn't happen automatically.  Notice the difference between your code and the example code I posted? Your code isn't preselecting anything. If you want to preselect a value, you have to add that code

Your Code
<select ...>
<cfloop query="ddvsnetwork">
<option>#ddvsnetwork.Network#</option>  <=== nothing is marked as "selected"!
</cfloop></select>

My Code:
<select ...>
<cfouput query="dropdownvalues">
        <option value="#dropdownvalues.itemID#" <cfif all.itemID eq dropdownvalues.itemID>selected="selected"</cfif>>#dropdownvalues.itemDescription#</option>
    </cfoutput>
</select>
0
 
jslaughtAuthor Commented:
Yeah I am building/testing a ticket tracking website with coldfusion as the front end and microsoft access as the backend database. I'm doing this locally until all is working well then I will deploy to our work server for testing/eventual use by our customers.
0
 
_agx_Commented:
If no new values are selected in a drop down list then the original value should stay the same when the update button is selected

ie That's your problem. When the form loads the code isn't pre-selecting the desired value. So the <select> defaults to the 1st item in the list.  That's how all html <select> lists behave.  If you want to select a different item, you have to add that to your code. It won't happen by itself.
0
 
_agx_Commented:
Oops... our posts crossed.  

So do you see what I'm saying about <select> lists?
0
 
jslaughtAuthor Commented:
i understood what you are saying about the <select> lists. However I changed my code to fit your example above and am now getting the following error message:

Invalid tag nesting configuration.  
A query driven cfoutput tag is nested inside a cfoutput tag that also has a query attribute. This is not allowed. Nesting these tags implies that you want to use grouped processing. However, only the top-level tag can specify the query that drives the processing

<cfquery name="dropdownvalues" datasource="sspsrs">
    SELECT Title_Name
    FROM IssueTitles
</cfquery>


<!--- your dsn ... --->
<cfset yourDSN = "SSPSRs">

<!--- ensure variables always exist. default to invalid values --->
<cfparam name="url.user_name" default="">
<cfparam name="URL.From" default="">
<cfparam name="URL.ID"  default="-1">
<cfset wasUpdated = false>

<!-- If URL.From is defined and equals DoEdit, then update the table -->
<CFIF URL.From eq "DoEdit">
    <CFUPDATE DATASOURCE="#yourDSN#" TABLENAME="Issues">
    <!--- clear the id to mark the update complete --->
    <cfset URL.id = -1>
    <cfset wasUpdated = true>
</CFIF>

<!-- The below code selects all data from the table -->
<CFQUERY NAME="all" DATASOURCE="#yourDSN#">
    SELECT    * 
    FROM    Issues 
    WHERE   status = 'active' and user_name = <cfqueryparam value="#url.user_name#" cfsqltype="cf_sql_varchar">
    <!--- if a ticket number exists, pull the information for editing --->
    <cfif url.id gt 0>
        AND    Ticket_Num = <cfqueryparam value="#url.id#" cfsqltype="cf_sql_integer">
    </cfif>
</CFQUERY>

<html>
<head></head>
<body>
	<!--- headers --->
    <cfoutput><a href="trackertabs.cfm?user_name=#url.user_name#&tab=2"></cfoutput>    
    <img src="http://127.0.0.1:8500/TicketTracking/pics/imagesCA6WFWX0.jpg" width=50 height=50 alt="go back to service tab" border="0" /></a><br>
    <center>
        <font size=6 font face="Copperplate Gothic Ligth">My Open Service Requests</font><br>
    </center>

    <!-- If DoUpdate has been run a short note is given -->
    <CFIF wasUpdated>
        <p><b>Thanks for your update!</b>
    </CFIF>
    
	<!--- table headers --->
    <table border='0' width='100%' align='center' summary='script output'>
    <tr bgcolor="#d3d3d3">
        <th bgcolor="#d3d3d3"><font size=2><b>Service<br> Request #</b></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Request</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Network</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Assigned To</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Last_Name</strong></font></th>
	<th bgcolor="#d3d3d3"><font size=2></strong>First_Name</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Opened Date</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Status</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Priority</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Description</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Date Completed</strong></font></th>
        <th bgcolor="#d3d3d3"><font size=2></strong>Comments</strong></font></th>
        <th></th>
    </tr>
    <!--- We are editing a single record .... --->
    <CFIF URL.ID IS all.Ticket_Num>
        <CFOUTPUT query="all">
            <cfform action="myopensrs.cfm?user_name=#url.user_name#&From=DoEdit&ID=#Ticket_num#" method="post">
                <tr bgcolor="iif(currentrow MOD 1,DE('123456'))">
                <td><font size=2>#Ticket_num#</font></td>

                <td><font size=2>#Title#
		<select name="Title">
		<cfoutput query="dropdownvalues">
		<option value="#dropdownvalues.titleid#"<cfif all.titleid eq dropdownvalues.titleid>selected="selected"</cfif>>#dropdownvalues.title_name#</option>
		</cfoutput>
		</select></font></td>

                <td><font size=2><input type="text" name="Network" size="15" value="#Network#"></font></td>
                <td><font size=2><input type="text" name="Assigned_To" size="25" value="#Assigned_To#"></font></td>
                <td><font size=2><input type="text" name="Customer" size="25" value="#Customer#"></font></td>
                <td><font size=2><cfinput type="datefield" name="Opened_Date" size="6" width="100" mask="mm/dd/yyyy" value="#DateFormat(Opened_Date,'mm/dd/yyyy')#"></font></td>
                <td><font size=2><input type="text" name="Status" size="10" value="#Status#"></font></td>
                <td><font size=2><input type="text" name="Priority" size="10" value="#Priority#"></font></td>
                <td><font size=2><input type="text" name="Description" size="30" value="#Description#"></font></td>
                <td><font size=2><input type="text" name="Date_Completed" size="10" value="#Date_Completed#"></font></td>
                <td><font size=2><input type="text" name="Comments" size="25" value="#Comments#"></font></td>
                </tr>
                <tr><td colspan="3">
                    <cfinput type="hidden" name="Ticket_num" value="#URL.ID#"><br><br><br>
                    <input type="submit">
                    </td>
                </tr>    
            </cfform>
        </CFOUTPUT>

    <!--- Otherwise we simply output all data --->
    <CFELSE>    
        <CFOUTPUT query="all">
            <tr bgcolor="###iif(currentrow MOD 2,DE('ffffff'),DE('ffff66'))#">
            <td><font size=2>#Ticket_num#</font></td>
            <td><font size=2>#Title#</font></td>
            <td><font size=2>#Network#</font></td>
            <td><font size=2>#Assigned_To#</font></td>
            <td><font size=2>#Last_Name#</font></td>
	    <td><font size=2>#First_Name#</font></td>
            <td><font size=2>#DateFormat(Opened_Date,'mm/dd/yyyy')#</font></td>
            <td><font size=2>#Status#</font></td>
            <td><font size=2>#Priority#</font></td>
            <td><font size=2>#Description#</font></td>
            <td><font size=2>#Date_Completed#</font></td>
            <td><font size=2>#Comments#</font></td>
            <!-- This is where the Edit button and form is created -->
            <td>
            <form action="myopensrs.cfm?user_name=#url.user_name#&From=Edit&ID=#Ticket_num#" method="post">
                <input type="submit" value="Edit">
            </form>
            </td>
        </tr>
        </CFOUTPUT>
    </CFIF>
</table>
</body>
</html>

Open in new window

0
 
_agx_Commented:
Oh, yeah.  Remember we fixed that error on the other thread?  If you're already using <cfoutput> outside the <select> then you have to change the <cfoutput query="..."> to a cfloop query="..".  

ie
<select ...>
<cfloop query="dropdownvalues">
        <option value="#dropdownvalues.itemID#" <cfif all.itemID eq dropdownvalues.itemID>selected="selected"</cfif>>#dropdownvalues.itemDescription#</option>
    </cfloop >
</select>
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 12
  • 7
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now