0
Adding an extra column
New Here
,
/t5/coldfusion-discussions/adding-an-extra-column/td-p/974353
Apr 29, 2008
Apr 29, 2008
Copy link to clipboard
Copied
My query will produce three records, so I output/display them
in a table :
<cfoutput query="qry">
<tr>
<td>#line_item#</td><td>#part_number#</td><td>#requestor#</td>
</tr>
</cfoutput>
What I need to do is add an extra column to the end of each record, to enter comments :
<td><input type="text" name="comments" size="50" maxlength="50"></td> so the new row will look like :
<td>#line_item#</td><td>#part_number#</td><td>#requestor#</td><td><input type="text" name="comments" size="50" maxlength="50"></td>
When the user enters the comments and submits the form, I want to insert the line_item, part_number, requestor, and comments into another table.
My question is how do I associate each comments text with the existing corresponding record ?
<cfoutput query="qry">
<tr>
<td>#line_item#</td><td>#part_number#</td><td>#requestor#</td>
</tr>
</cfoutput>
What I need to do is add an extra column to the end of each record, to enter comments :
<td><input type="text" name="comments" size="50" maxlength="50"></td> so the new row will look like :
<td>#line_item#</td><td>#part_number#</td><td>#requestor#</td><td><input type="text" name="comments" size="50" maxlength="50"></td>
When the user enters the comments and submits the form, I want to insert the line_item, part_number, requestor, and comments into another table.
My question is how do I associate each comments text with the existing corresponding record ?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/adding-an-extra-column/m-p/974354#M88936
Apr 29, 2008
Apr 29, 2008
Copy link to clipboard
Copied
Use the name attribute of your cfinput tag. instead of simply
comments, call it comments#something_from_your_query#
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Trojan_Fan
AUTHOR
New Here
,
/t5/coldfusion-discussions/adding-an-extra-column/m-p/974355#M88937
Apr 29, 2008
Apr 29, 2008
Copy link to clipboard
Copied
I changed the name from coments to comments-#line_item# and
when I display it, it is comments_6, which correponnds to the
line_item (6) that is retrieved and displayed.
Now how/what do I do to insert the value of the comments into the table so that it corresponds to the line item,in this case, 6 ?
Now how/what do I do to insert the value of the comments into the table so that it corresponds to the line item,in this case, 6 ?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/adding-an-extra-column/m-p/974356#M88938
Apr 30, 2008
Apr 30, 2008
Copy link to clipboard
Copied
I'll be doing something like that later today. My method goes
something like this.
<cfloop list="#form.fieldnames#" index = "ThisItem">
<cfif left(ThisItem, 9) is "comments_">
<cfset ThisRecord = Mid(ThisItem, 10, len(ThisItem - 9))>
<cfset ThisValue = form[ThisItem]>
code to do somehing with those variables
closing tags.
<cfloop list="#form.fieldnames#" index = "ThisItem">
<cfif left(ThisItem, 9) is "comments_">
<cfset ThisRecord = Mid(ThisItem, 10, len(ThisItem - 9))>
<cfset ThisValue = form[ThisItem]>
code to do somehing with those variables
closing tags.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Trojan_Fan
AUTHOR
New Here
,
/t5/coldfusion-discussions/adding-an-extra-column/m-p/974357#M88939
May 01, 2008
May 01, 2008
Copy link to clipboard
Copied
I think I understand what you are doing here.
However, here is my original post and methods, how would I incorporate your method into this one ?
I use the following code to display display all line items from a query, and put in checkboxes for each line item, so that if the box is checked, that line item will be deleted :
<cfoutput query="qry">
<tr>
<td align="center"><input type="checkbox" name="del_#urdn_number#_#urdn_line_item#" value="Yes"></td>
<td align="center">#qry.line_item#</td>
<td align="center">#qry.action#</td>
<td align="center">#qry.quantity#</td>
the action page :
<cfloop index="i" list="#form.fieldnames#" delimiters=",">
<cfif left(i,4) is "del/">
<cfset select_urdn_number = listgetat(i, 2, "/")>
<cfset select_urdn_line_item = listlast(i, "/")>
What I need to do now is add a input text field, to each line item displayed, for the user to enter comments explaining why they watn to delete that line item. I then need to insert this comment that corresonds to each line item into a table.
Since this comments input text is not part of the query, how do I associate it with each line item ?
However, here is my original post and methods, how would I incorporate your method into this one ?
I use the following code to display display all line items from a query, and put in checkboxes for each line item, so that if the box is checked, that line item will be deleted :
<cfoutput query="qry">
<tr>
<td align="center"><input type="checkbox" name="del_#urdn_number#_#urdn_line_item#" value="Yes"></td>
<td align="center">#qry.line_item#</td>
<td align="center">#qry.action#</td>
<td align="center">#qry.quantity#</td>
the action page :
<cfloop index="i" list="#form.fieldnames#" delimiters=",">
<cfif left(i,4) is "del/">
<cfset select_urdn_number = listgetat(i, 2, "/")>
<cfset select_urdn_line_item = listlast(i, "/")>
What I need to do now is add a input text field, to each line item displayed, for the user to enter comments explaining why they watn to delete that line item. I then need to insert this comment that corresonds to each line item into a table.
Since this comments input text is not part of the query, how do I associate it with each line item ?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/adding-an-extra-column/m-p/974358#M88940
May 01, 2008
May 01, 2008
Copy link to clipboard
Copied
Give all the checkboxes the same name and different values.
For the comments, read the thread again, the answer is the
same.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Trojan_Fan
AUTHOR
New Here
,
/t5/coldfusion-discussions/adding-an-extra-column/m-p/974359#M88941
May 01, 2008
May 01, 2008
Copy link to clipboard
Copied
I cant seem to get this to work.
<cfloop list="#form.fieldnames#" index = "ThisItem">
<cfif left(ThisItem, 9) is "comments_">
<cfset ThisRecord = Mid(ThisItem, 10, len(ThisItem - 9))>
<cfset ThisValue = form[ThisItem]>
ThisValue is the content of the comments_6, which corresonds to line item 6 ? I did a cfoutput and it show Yes.
I just need to get the each comments entry to correspond to the approriate line iteme records.
<cfloop list="#form.fieldnames#" index = "ThisItem">
<cfif left(ThisItem, 9) is "comments_">
<cfset ThisRecord = Mid(ThisItem, 10, len(ThisItem - 9))>
<cfset ThisValue = form[ThisItem]>
ThisValue is the content of the comments_6, which corresonds to line item 6 ? I did a cfoutput and it show Yes.
I just need to get the each comments entry to correspond to the approriate line iteme records.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/adding-an-extra-column/m-p/974360#M88942
May 02, 2008
May 02, 2008
Copy link to clipboard
Copied
What happens when you output the ThisRecord variable.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Trojan_Fan
AUTHOR
New Here
,
LATEST
/t5/coldfusion-discussions/adding-an-extra-column/m-p/974361#M88943
May 12, 2008
May 12, 2008
Copy link to clipboard
Copied
I need help with this again, almost works but not quite.
Here is the code I have for my form :
<cfoutput query="qry">
<tr>
<td align="center"><cfinput type="checkbox" name="del/#ref_number#/#ref_line_item#" value="Yes"></td>
<td align="center">#ref_line_item#</td>
<td align="center">#ref_action#</td>
<td align="center">#quantity#</td>
<cfif qry.ref_action is "Receive">
<td>PO: #qry.po_number#,
Item: #qry.item#, P/N: #qry.part_number#</td>
<cfelseif qry.ref_action is "RTV">
<td>Shipping Document Number: #qry.tracking_number#</td>
<cfelseif qry.ref_action is "Other">
<td>Instructions: #qry.instructions#</td>
</cfif>
<td align="center"><cfinput type="text" name="comments/#ref_number#/#ref_line_item#" size="50" maxlength="50"></td>
</tr>
</cfoutput>
I am,attepting to associate the commets field with the checkbox field.
Here is my action page :
<cfif isDefined("form.fieldnames") and mid(form.fieldnames,1,4) is "Del/">
<cfloop index="i" list="#form.fieldnames#" delimiters=",">
<cfif left(i,4) is "del/">
<cfset select_ref_number = listgetat(i, 2, "/")>
<cfset select_ref_line_item = listlast(i, "/")>
<cfset commentsName = "comments/#select_ref_number#/#select_ref_line_item#">
<cfset select_comments = form[commentsName]>
<cfif select_comments is "">
<cflocation url="form.cfm?showAlert&ref_number=#select_ref_number#&line_item=#select_ref_line_item#">
</cfif>
update query goes here
</cfif>
</cfloop>
<cfoutput>
<cflocation url="next_form.cfm?ref_number=#form.ref_number#">
</cfoutput>
<cfelse>
<cfoutput>
Error Message goes here
</cfoutput>
</cfif>
If none of the checkboxes are selected and the form submitted, I need to display an error message. If any of the chekcboxes are selected but the comments are blank, then I need to display anohter error message.The form should only submit if at least one of the checkboxes are checked and there are commets.
It seems to work halfway. If the errors are detected, and corrected, the errors continue to come up. If it is done right the first time (checkbox and commerts), it seems to work fine.
But overall, I think it is not working.
Can someone please help and tell me what I am doing wrong ?
Thanks
Here is the code I have for my form :
<cfoutput query="qry">
<tr>
<td align="center"><cfinput type="checkbox" name="del/#ref_number#/#ref_line_item#" value="Yes"></td>
<td align="center">#ref_line_item#</td>
<td align="center">#ref_action#</td>
<td align="center">#quantity#</td>
<cfif qry.ref_action is "Receive">
<td>PO: #qry.po_number#,
Item: #qry.item#, P/N: #qry.part_number#</td>
<cfelseif qry.ref_action is "RTV">
<td>Shipping Document Number: #qry.tracking_number#</td>
<cfelseif qry.ref_action is "Other">
<td>Instructions: #qry.instructions#</td>
</cfif>
<td align="center"><cfinput type="text" name="comments/#ref_number#/#ref_line_item#" size="50" maxlength="50"></td>
</tr>
</cfoutput>
I am,attepting to associate the commets field with the checkbox field.
Here is my action page :
<cfif isDefined("form.fieldnames") and mid(form.fieldnames,1,4) is "Del/">
<cfloop index="i" list="#form.fieldnames#" delimiters=",">
<cfif left(i,4) is "del/">
<cfset select_ref_number = listgetat(i, 2, "/")>
<cfset select_ref_line_item = listlast(i, "/")>
<cfset commentsName = "comments/#select_ref_number#/#select_ref_line_item#">
<cfset select_comments = form[commentsName]>
<cfif select_comments is "">
<cflocation url="form.cfm?showAlert&ref_number=#select_ref_number#&line_item=#select_ref_line_item#">
</cfif>
update query goes here
</cfif>
</cfloop>
<cfoutput>
<cflocation url="next_form.cfm?ref_number=#form.ref_number#">
</cfoutput>
<cfelse>
<cfoutput>
Error Message goes here
</cfoutput>
</cfif>
If none of the checkboxes are selected and the form submitted, I need to display an error message. If any of the chekcboxes are selected but the comments are blank, then I need to display anohter error message.The form should only submit if at least one of the checkboxes are checked and there are commets.
It seems to work halfway. If the errors are detected, and corrected, the errors continue to come up. If it is done right the first time (checkbox and commerts), it seems to work fine.
But overall, I think it is not working.
Can someone please help and tell me what I am doing wrong ?
Thanks
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

