?
Solved

produce an <input type="select"> when editing a table row in a table

Posted on 2011-04-26
19
Medium Priority
?
392 Views
Last Modified: 2012-05-11
Hello Experts. The below code works successfully for what I need it to do. It allows an edit of data in a table row. What I would like for my coldfusion code to do further is display and allow selection from combo boxes during an table row edit. Some of the data comes from a database table where the values are in a combo box list. This would be great during an edit. I know I could do a <input type="select"  of a table row by listing the value options but what if more values are added in the database table at a later date? How does the <input type="select"> values get updated then? It would be nice via a cfquery?   Hopefully my question makes sense and thanks in advance.
<!-- 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>


<!-- The below code selects all data from the table -->

<CFQUERY NAME="all" DATASOURCE="SSPSRs">
select * from Issues where user_name = <cfoutput>'#url.user_name#'</cfoutput>;
</CFQUERY>



<body>
<a href="trackertabs.cfm?user_name=<cfoutput>#url.user_name#</cfoutput>&tab=2">
<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> 
</body>
<br>

<body> 
<center>
<font size=6 font face="Copperplate Gothic Ligth">
My Service Requests (All)
</font>
</center>
<br>
</body>


<body>

<!-- If DoUpdate has been run a short note is given -->

<CFIF IsDefined("DoUpdate.RecordCount")>
<p><b>Thanks for your update!</b>
</CFIF>



<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>

<!-- Here we check for the URL.From attribute -->

<CFIF IsDefined("URL.From")>

<!-- If URL.From just equals DoEdit, we simply just output the data, just as if it was undefined  -->

<CFIF #URL.From# IS "DoEdit">



<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>

<CFELSE>

<CFLOOP QUERY="all">

<CFIF #URL.ID# IS #all.Ticket_Num#>

<CFOUTPUT>

<form 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><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>

<CFELSE>

<!-- This is where all the data get's nicely output into the table -->

<cfoutput>
<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>
<td>
</td>
</tr>
</CFOUTPUT>

</CFIF>

</CFLOOP>

</CFIF>

<!-- If URL.From is undefined -->

<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>

<!-- If URL.From is defined and equals Edit, then display an update button and close the form -->

<CFIF IsDefined("URL.From")>
<CFIF #URL.From# IS "Edit">

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

</CFIF>
</CFIF>

</table>

</body>

Open in new window

0
Comment
Question by:jslaught
19 Comments
 
LVL 1

Assisted Solution

by:tampatechtiger
tampatechtiger earned 200 total points
ID: 35472292
I'm not exactly sure what your question is...but if I have guessed correctly, you're looking for a structure like the following:

<cfquery name="dropdownvalues" datasource="yourDSN">
    SELECT ItemID, ItemDescription
    FROM table_dropdownitems
</cfquery>

<select name="dropdown">
    <cfouput query="dropdownvalues">
        <option value="#dropdownvalues.itemID#">#dropdownvalues.itemDescription#</option>
    </cfoutput>
</select>\

That will query your DB each time the page is rendered, pull the (current) list of dropdown options from the relevant table and populate the select-input drop-down list with those values dynamically.  If the database records change, the next time the page is rendered it will display the changes.

0
 
LVL 13

Expert Comment

by:ansudhindra
ID: 35473018
in the above code you can add one more checking for current selected item.

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

Open in new window

0
 

Author Comment

by:jslaught
ID: 35478353
Your code above is where I need to get my code. I'm still not getting the result I strive for.  This is what my code should do and display:

1. There is a displayed .cfm page of results.
2. The edit capability (edit buttons are displayed for each row of displayed results) is implemented on the page via the coldfusion code.
3. User clicks an edit button to edit a row of results.
4. The row is highlighted for edit.
5. User changes the values as needed during the edit.
6. Some of the edited values should be selectable via a drop down box (values listed per a cfquery).  
7. user clicks "update"

With my current code I am able to do an edit and change the text values successfully. It would be nice to be able to allow drop down boxes for values that need to be changed.

Unfortunately I still haven't had any luck getting what I want to happen with my code.  With the code example below I just wanted to see if it would put a drop down box for manual <input type="select" name="Title">

<CFOUTPUT>

<form 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="select" name="Title"><option>Password Request</option></input></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><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
Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

 
LVL 52

Expert Comment

by:_agx_
ID: 35478543
> <input type="select" name="Title">

AFAIK there is no such thing as <input type="select">. If you want to create a drop down list, you have to use a <select> element as the other 2 experts showed.  Whatever elements you want displayed in the drop down list should come from a *separate* query.

ie Not the "all" query you seem to be using for the main form.

<CFQUERY NAME="all" DATASOURCE="SSPSRs">
select * from Issues where user_name = <cfoutput>'#url.user_name#'</cfoutput>;
</CFQUERY>
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35480137
( no points please.  i'm just paraphrasing what tampatechtiger already said ...)


In other words, to display a drop down list you have to use a <select> element not <input>
ie
        <select name="Title"><option>Password Request</option></select>


... selectable via a drop down box (values listed per a cfquery).

If you want to populate the list items from a db, you need to run a separate query. Grab the values from your db table:

<cfquery name="getListValues" datasource="yourDSN">
    SELECT TheListID, TheListText
    FROM    YourTableOfValues
</cfquery>

Open in new window


Then use cfoutput to generate the list <options>:
 
<select name="Title">
    <cfouput query="getListValues">
        <option value="#getListValues.TheListID#">#getListValues.TheListText#</option>
    </cfoutput>
</select>

Open in new window

0
 

Author Comment

by:jslaught
ID: 35480353
I guess I'm just not getting it. When I run the following suggested code by itself it displays the drop down:

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

<td><select name="dropdown">
<cfoutput query="dropdownvalues">
<option>#dropdownvalues.title_name#</option>
</cfoutput></select></td>

When I run the code above within my <cfupdate> code excerpt below I am not successful at getting an dropdown within a table row. I am getting the following error: 'The value of the attribute query, which is currently dropdownvalues, is invalid."  

Thanks in advance for bearing with me as I try to get this right.
<cfquery name="dropdownvalues" datasource="sspsrs">
    SELECT titleid, Title_Name
    FROM IssueTitles
</cfquery>


<CFOUTPUT>



<form 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><select name="dropdown"><cfoutput query="dropdownvalues"><option value="#dropdownvalues.titleid#>#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><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
 
LVL 52

Expert Comment

by:_agx_
ID: 35485461
No, I think you're getting it now.  

But that error is saying the query didn't actually run.  Your main form has a lot of cfif/cfelse's in it. So I'm guessing the cfquery isn't executing at the right time.  As a test, place it at the very top of your page.  Make sure it's *not* inside a cfif/cfelse

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

<!-- If URL.From is defined and equals DoEdit, then update the table -->
<CFIF IsDefined("URL.From")>
<CFIF #URL.From# IS "DoEdit">
.... rest of code 

Open in new window

0
 

Author Comment

by:jslaught
ID: 35486505
Took the last suggestion above from expert by placing the dropdownvalues cfquery at the top of the page and refreshing the page. Now i'm 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. Below is my full code for the page i'm trying to run successfully.

I continue to appreciate the help and patience you guys are providing. This is definitely a hump in my development I can't wait to get over.
<cfquery name="dropdownvalues" datasource="sspsrs">
    SELECT titleid, Title_Name
    FROM IssueTitles
</cfquery>

<!-- 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>


<!-- The below code selects all data from the table -->

<CFQUERY NAME="all" DATASOURCE="SSPSRs">
select * from Issues where user_name = <cfoutput>'#url.user_name#'</cfoutput>;
</CFQUERY>



<body>
<a href="trackertabs.cfm?user_name=<cfoutput>#url.user_name#</cfoutput>&tab=2">
<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> 
</body>
<br>

<body> 
<center>
<font size=6 font face="Copperplate Gothic Ligth">
My Service Requests (All)
</font>
</center>
<br>
</body>


<body>

<!-- If DoUpdate has been run a short note is given -->

<CFIF IsDefined("DoUpdate.RecordCount")>
<p><b>Thanks for your update!</b>
</CFIF>



<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>

<!-- Here we check for the URL.From attribute -->

<CFIF IsDefined("URL.From")>

<!-- If URL.From just equals DoEdit, we simply just output the data, just as if it was undefined  -->

<CFIF #URL.From# IS "DoEdit">



<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>

<CFELSE>

<CFLOOP QUERY="all">

<CFIF #URL.ID# IS #all.Ticket_Num#>

<CFOUTPUT>

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

<tr bgcolor="iif(currentrow MOD 1,DE('ffffff'))">
<td><font size=2>#Ticket_num#</font></td>
<td><font size=2>#Title#<select name="dropdown"><cfoutput query="dropdownvalues"><option value="#dropdownvalues.titleid#>#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><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>

<CFELSE>

<!-- This is where all the data get's nicely output into the table -->

<cfoutput>
<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>
<td>
</td>
</tr>
</CFOUTPUT>

</CFIF>

</CFLOOP>

</CFIF>

<!-- If URL.From is undefined -->

<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>

<!-- If URL.From is defined and equals Edit, then display an update button and close the form -->

<CFIF IsDefined("URL.From")>
<CFIF #URL.From# IS "Edit">

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

</CFIF>
</CFIF>

</table>

</body>

Open in new window

0
 
LVL 52

Accepted Solution

by:
_agx_ earned 800 total points
ID: 35486649
Ok that's good progress.  

Since you're already using a cfoutput outside the form you can't use one around the <select>. But you can use a cfloop instead and it'll work fine.

ie Change this

<select name="dropdown">
<cfoutput query="dropdownvalues">
<option value="#dropdownvalues.titleid#>#dropdownvalues.title_name#</option>
</cfoutput>
</select>

to this:

<select name="dropdown">
<cfloop query="dropdownvalues">
<option value="#dropdownvalues.titleid#>#dropdownvalues.title_name#</option>
</cfloop>
</select>
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35486751
<input type="text" name="Title" size="25" value="#Title#">
<select name="dropdown">

By the way, the original expert named the <select> "dropdown" just as an example.  You probably want to change it back to "title" so your <cfupdate> works just like before.

ie <select name="Title">
0
 

Author Comment

by:jslaught
ID: 35487963

Yes we have success! Almost over the hump! I have one small problem though. After editing a value in the tablerow and clicking the update button.... the original value does not get overwritten by the new value. So now the original value in the record and the new value are both being displayed and separated by a comma. How do I fix this. Thanks in advance.




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

<!-- 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>


<!-- The below code selects all data from the table -->

<CFQUERY NAME="all" DATASOURCE="SSPSRs">
select * from Issues where user_name = <cfoutput>'#url.user_name#'</cfoutput>;
</CFQUERY>



<body>
<a href="trackertabs.cfm?user_name=<cfoutput>#url.user_name#</cfoutput>&tab=2">
<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> 
</body>
<br>

<body> 
<center>
<font size=6 font face="Copperplate Gothic Ligth">
My Service Requests (All)
</font>
</center>
<br>
</body>


<body>

<!-- If DoUpdate has been run a short note is given -->

<CFIF IsDefined("DoUpdate.RecordCount")>
<p><b>Thanks for your update!</b>
</CFIF>



<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>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>

<!-- Here we check for the URL.From attribute -->

<CFIF IsDefined("URL.From")>

<!-- If URL.From just equals DoEdit, we simply just output the data, just as if it was undefined  -->

<CFIF #URL.From# IS "DoEdit">

<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>#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>


<CFELSE>

<CFLOOP QUERY="all">

<CFIF #URL.ID# IS #all.Ticket_Num#>

<CFOUTPUT>



<form 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#">
<select name="Title">
<cfloop query="dropdownvalues">
<option>#dropdownvalues.title_name#</option>
</cfloop>
</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="Last_Name" size="25" value="#Last_Name#"></font></td>
<td><font size=2><input type="text" name="First_Name" size="25" value="#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>

<CFELSE>

<!-- This is where all the data get's nicely output into the table -->

<cfoutput>
<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>#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>
<td>
</td>
</tr>
</CFOUTPUT>

</CFIF>

</CFLOOP>

</CFIF>

<!-- If URL.From is undefined -->

<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>#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>

<!-- If URL.From is defined and equals Edit, then display an update button and close the form -->

<CFIF IsDefined("URL.From")>
<CFIF #URL.From# IS "Edit">

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

</CFIF>
</CFIF>

</table>

</body>

Open in new window

0
 
LVL 52

Expert Comment

by:_agx_
ID: 35488134
Oops.  Sorry that extra <input> field was a copy paste error.  Just get rid of it because you've replaced it with the <select> list:

ie Remove this
<input type="text" name="Title" size="25" value="#Title#">

0
 

Author Comment

by:jslaught
ID: 35488377
All is now working the way I need it to! Appreciate you sticking with me on this one. I will definitely increase the point value for all the help. Can I throw in another quick question (laugh)?

I notice that when the edit button is clicked to edit a table row... the description field that's editable displays <div> tags before and after the description text. Why is that?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35488446
I don't see anything in the code that would cause that.  It's just plain form tags.  Any chance your possible your db record actually contains the <div> tags? Because that would explain it.
0
 

Author Comment

by:jslaught
ID: 35488564
no <div> tags in any of the database records as I can see . I'm using a Microsoft Access db. The only thing I can think of is the fact that the datatype for the description field is a memo type. Not sure if that matters or not. I changed it to a text datatype and gave it a 255 field size. Added a new record and then edited on the webpage. No <div> tags for that record. I can live with that for now.

Additional question... i will increase the point value for the additional help.

I have a date field that could be edited during the cfupdate. How would I go about adding a calendar (date picker) to my edit capability? Thanks again in advance.

0
 
LVL 52

Expert Comment

by:_agx_
ID: 35488677
(Not about points I'm happy to answer any questions .. ) but it's actually better (and EE policy) to put separate/new questions on a new thread. One question per thread makes it easier for people searching to find solutions :)
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35488685
fact that the datatype for the description field is a memo type.

I don't use Access much. But I don't think it should make a difference. I didn't even see any <div> tags in the code either.  Does it happen for every edit?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35488705
Just continuing on the <div> tag mystery, is there any other code in the page we can't see? Like maybe some extra javascript, etc...?
0
 

Author Closing Comment

by:jslaught
ID: 35488816
I appreciate the assistance with my question. Lots of patience and good explanations until I finally got the result I needed.
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

839 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