Copy link to clipboard
Copied
Hi,
I'm not sure if this is possible or not, but I have 2 different columns in a display page- 1 for PNR Initials and 1 for BOM Initials, but when I insert everything into the database, I only have 1 column to handle both the PNR and BOM initials. The way I tell them apart is with another column that is called Document_Type. If it says "PNR Req", then I know to output it into the PNR Initials column. If it says "BOM Req", then I know to outupt it into the BOM Initials column.
Although the inserting works correctly, the display page does not put them next to each other since the data is dynamic and it's outputting each column's initials into their own rows. For instance, I updated the PNR Initial to "VP" and hit the update or insert button and it inserted the PNR Initial into the database. Then I went back to the display page to insert the BOM Initial to "AG". It inserted it correctly. But now when I go back to the display page, there are 2 different rows with the first row that has the drop down menu in the PNR Column and "AG" in the BOM column. But then there is another row that has "VP" in the PNR column and the drop down menu in the BOM column. Since I've updated both columns, it should just show the PNR Initials under the PNR column once and the BOM Initials under the BOM column once, but all in the same row and not on 2 separate rows. How do I get it so they show up on the same row? The 2 different rows are indicated by the APVID 5 and 9, but they both are linked to the same item number 5 in the Items table. Here's what my display page looks like now:
APVID | APV_ItemID | Part_Number | PNR | BOM |
---|---|---|---|---|
5 | 5 | aaa5 | Drop Down Menu | AG |
9 | 5 | aaa5 | VP | Drop Down Menu |
It should look like this:
APVID | APV_ItemID | Part_Number | PNR | BOM |
---|---|---|---|---|
5 and 9 | 5 | aaa5 | VP | AG |
The APV_ItemID is linked to a column in another table. That table is the ECO_Items table that has the ItemID column that has all the items. The info. above for the APV_ItemID and Part number can always all be the same, but the PNR and BOM columns have to display the correct initals in each on 1 line. I tried the maxrows and the group function on the output query, but those did not work. I've also tried some IF statements, but they do not work either. Any other ideas? Is this even possible?Thanks.
Andy
Copy link to clipboard
Copied
Sounds like a job for the group by attribute of the cfoutput tag.
Copy link to clipboard
Copied
Dan,
That's what I tried, but it only displays the first item row with the PNR Initials, but then the BOM initials have a drop down menu still in it and not the "AG" initials that are in the database already for that item. It basically deletes the 2nd row or the 2nd item and only displays the first row of information. Do I need to run 2 different output queries with the group attribute? One for the PNR Initals column and one for the BOM initials column? I've tried this too, but the table gets really messed up and doesn't line up normal.
Andy
Copy link to clipboard
Copied
Here's what my code looks like for this table. Is there anything I can do since the code is being output dynamically?
<table width=*% align="center" cellspacing="0" cellpadding="4" border="0">
<tr>
<td><B>ECO</B> </td>
<td><B>ECO ItemID</B> </td>
<td><B>APVID</B> </td>
<td><B>APV ItemID</B> </td>
<td><B>Part Number </B></td>
<td align="center"><B>PNR</B></td>
<td align="center"><B>BOM</B></td>
<td align="center"><B>Open Jobs Affected</B></td>
</tr>
<!---------------- OUTPUT Company SEARCH RESULTS ---------------->
<cfform name="EditItem" method="post" action="Queue_PNR_BOM_action.cfm">
<CFOUTPUT QUERY="PNRBOMSearch">
<input type="hidden" name="ECID#ItemID#" value="#ECID#">
<input type="hidden" name="ItemID#ItemID#" value="#ItemID#">
<input type="hidden" name="PNR_Doc_Type#ItemID#" value="PNR Req">
<input type="hidden" name="BOM_Doc_Type#ItemID#" value="BOM Req">
<tr>
<td>
<cfif ECID is not "">
<a href="item_display.cfm?ECID=#ECID#">#ECID#</a>
<cfelse>
</cfif></td>
<td width="auto">
<cfif ItemID Is Not "">
#ItemID#
<cfelse>
</cfif></td>
<td width="auto">
<cfif APVID Is Not "">
#APVID#
<cfelse>
</cfif></td>
<td width="auto">
<cfif APV_ItemID Is Not "">
#APV_ItemID#
<cfelse>
</cfif></td>
<td width="auto">
<cfif Part_Number Is Not "">
#Part_Number#
<cfelse>
</cfif></td>
<td align="center">
<cfif Approval_Initials Is Not "" and Document_Type EQ "PNR Req">
#Approval_Initials#
<cfelse>
<select name="PNR_Approval_Initials#ItemID#">
<option value="">Select Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
</cfif>
</td>
<td align="center">
<cfif Approval_Initials Is Not "" and Document_Type EQ "BOM Req">
#Approval_Initials#
<cfelse>
<select name="BOM_Approval_Initials#ItemID#">
<option value="">Select Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
</cfif>
</td>
<!--- <td>
<select name="BOM_Approval_Initials#ItemID#">
<option value="">Select Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#"
<cfif #Initials# EQ #PNRBOMSearch.Approval_Initials#>selected</cfif>>#Initials#</option>
</cfif>
</cfloop>
</select>
</td> --->
<td><input name="Open_Jobs_Affected#ItemID#" type="text" value="#Trim(Open_Jobs_Affected)#" size="30"></td>
</tr>
<!--- </CFLOOP> --->
</cfoutput>
<tr>
<td>
</td>
</tr>
<tr>
<td colspan="4" align="center">
<input type="submit" value="Update">
<input type="reset" value="Reset"></td>
</tr>
</table>
<cfoutput>
<input type="hidden" name="listofids" value="#ValueList(PNRBOMSearch.ItemID)#">
<!--- <input type="hidden" name="listofapvids" value="#ValueList(PNRBOMSearch.APV_ItemID)#"> --->
</cfoutput>
</cfform>
Andy
Copy link to clipboard
Copied
I don't see a group by attribute in your cfoutput tag anywhere. When you tried it, did you have the appropriate order by clause in your query?
Copy link to clipboard
Copied
Dan,
This is how I did the output query:
<CFOUTPUT QUERY="PNRBOMSearch" group="APV_ItemID">
How do you have an Order By on an output query tag?
Andy
Copy link to clipboard
Copied
The group parameter of an <cfoutput...> tag works by by looking for changing values in a column of the record set. To get the normally expected output from this, one would usually use the ORDER BY clause in the query that created the record set so that all the records with the same value for that ordered column are grouped together.
I.E.
<cfquery name="myQuery">
SELECT aField, bField, cField
FROM aTable
ORDER BY cField
</cfquery>
...
<cfoutput query="myQuery" group="cField">
<!--- output data once per value change in cField column --->
<cfoutput>
<!--- output data once per row in the recordset --->
</cfoutput>
<!--- output data once per value change in cField column --->
</cfoutput>
Message was edited by: ilssac Updated to correct my mix up of GROUP and ORDER that I so often do when typing on this subject.
Copy link to clipboard
Copied
Ilssac,
I tried the Order By and the Group By like you have it, but when I do a Group By, it combines my 2 rows and only outputs the first results row. How can I have only specific columns from the 2nd row outputing onto the first row of the Group when everything is being output dynamically? What do the 3 different outputs you have below mean? What do you mean by Record Set? Do you just mean outputting the whole table record set? Is there more to this than just Order By something and Output the query with a Group By something? Is that what the other 3 outputs you have below are for?
Andy
Copy link to clipboard
Copied
Record set is another term for query results.
To a certain extent, this really is as simple as having an order by clause in your query, and grouping by the same field in your output. Where it gets tricky is when you want to group by more than one field. It appears that's what you are attempting. To do so, order by more than one field and use nested cfoutputs, something like this:
select a, b, c, d
from etc
order by a, b, c
<cfoutput group="a">
#grouped data#
<cfoutput group="b">
#grouped data#
<cfoutput group="c">
#grouped data#
<cfoutput>
#ungrouped data#
closing tags.
Copy link to clipboard
Copied
Ilssac or Dan,
I'm still confused. I am trying to make this work on an edit page because I want to edit the approval initials for each item for the PNR Column and the BOM Column. This page is not an action page that just outputs info. from the previous page, so I need to have the query parameters in the output tags. How do I do that?
Another thing, I'm curious on how to do this into a table. I kept copying and pasting my whole table with the output tags like your example showed, but it was repeated over and over again and created a real mess of a table. Do I need to use the Maxrows function too? When you say "#grouped data#" does that mean all of the columns I want displayed from the table, or just the 2 columns for the PNR and BOM?
Do you guys know of any full working samples I could look at that have this output into a table somewhere?
Andy
Copy link to clipboard
Copied
<!--- <cfscript block to manually build a query recordset as I have know idea about your database --->
<cfscript>
aRecordSet = queryNew("aField,bField,cField");
queryAddRow(aRecordSet,5);
querySetCell(aRecordSet,"aField","Red",1);
querySetCell(aRecordSet,"aField","Red",2);
querySetCell(aRecordSet,"aField","Red",3);
querySetCell(aRecordSet,"aField","Blue",4);
querySetCell(aRecordSet,"aField","Blue",5);querySetCell(aRecordSet,"bField","Wagon",1);
querySetCell(aRecordSet,"bField","Ball",2);
querySetCell(aRecordSet,"bField","Ball",3);
querySetCell(aRecordSet,"bField","Wagon",4);
querySetCell(aRecordSet,"bField","Ball",5);querySetCell(aRecordSet,"cField","John",1);
querySetCell(aRecordSet,"cField","Suzie",2);
querySetCell(aRecordSet,"cField","John",3);
querySetCell(aRecordSet,"cField","Suzie",4);
querySetCell(aRecordSet,"cField","Joe",5);
</cfscript><cfdump var="#aRecordSet#">
<cfoutput query="aRecordSet" group="aField">
<h1>Color: #aRecordSet.aField#</h1>
<cfoutput group="bField">
<h2>Toy: #aRecordSet.bField#</h2>
<ul>
<cfoutput>
<li>#aRecordSet.cField#</li>
</cfoutput>
</ul>
</cfoutput>
</cfoutput>
Note how in the output the two colors, red and blue where only output once. Same with the categories: ball and wagon under each color category.
Start with some simple linear output like this, get your concepts of query order and cfoutput grouping down. Then you can move on to the more complex output of a table. With tables you will have add logic to account for row spans and|or empty cells.
Copy link to clipboard
Copied
Ilssac,
Thank you! This finally works! I am able to get the initials to show up side by side now. I just have one more question though. I want some If statements that say that if the initials are filled out for either the PNR or BOM, then just display them. (This is what I have working so far.) Else if the initials are blank, I want a drop down menu to be displayed so the user can choose some initials to be added to the database. But when I try and put a drop down menu in there, it creates 3 columns of drop downs. Why would it create 3 drop downs? I will only ever have 2 drop downs per row since I only have a PNR and a BOM column. How can I get this narrowed down to only 2 drop downs per row and how can I write the If statement? I basically need an If Statement for the PNR column and one for the BOM column. Or can I combine the 2 somehow? Here's what I have so far:
<table width=*% align="center" cellspacing="0" cellpadding="4" border="0">
<tr>
<td><B>APVID</B> </td>
<td><B>APV ItemID</B></td>
<td align="center"><B>PNR</B></td>
<td align="center"><B>BOM</B></td>
</tr>
<cfform name="EditItem" method="post" action="Queue_PNR_BOM_action.cfm">
<CFOUTPUT QUERY="PNRBOMSearch" group="APV_ItemID">
<tr>
<td>
#APVID#
</td>
<CFOUTPUT group="APV_ItemID">
<td>
#APV_ItemID#
</td>
<CFOUTPUT>
<td>
<cfif Approval_Initials Is Not "" and Document_Type EQ "PNR Req">
#Approval_Initials#
</td>
<td align="center">
<cfelseif Approval_Initials Is "">
<select name="PNR_Approval_Initials#ItemID#">
<option value="">Select Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
</cfif>
</td>
</cfoutput>
</cfoutput>
</cfoutput>
</tr>
<tr>
<td colspan="4" align="center">
<input type="submit" value="Update">
<input type="reset" value="Reset"></td>
</tr>
</table>
Thanks!
Andy
Copy link to clipboard
Copied
jamie61880 wrote:
<td>
<cfif Approval_Initials Is Not "" and Document_Type EQ "PNR Req">
#Approval_Initials#
</td>
<td align="center">
<cfelseif Approval_Initials Is "">
<select name="PNR_Approval_Initials#ItemID#">
<option value="">Select Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
</cfif>
</td>
Eliminate the extra <td> tags in the middle of your if else block. You want to use the condition statement to determine the contet's of the given cell. Not create new cells conditionally.
Copy link to clipboard
Copied
Ilssac,
That worked! I did have to change my first group item to ItemID and then I took off the td tags and I'm almost there. The only problem I have left is the drop down menu is only showing up under the PNR column. These are the 3 things I need it to do:
Drop down has to show up under each column if no initials are filled in at all for that ECO number.
If Initials are in the PNR column and none in the BOM column, then the BOM column needs to have the drop down.
If Initials are in the BOM column and none in the PNRcolumn, then the PNR column needs to have the drop down.
How do I write this If statement? Here's how I have the group items and the table again:
<cfform name="EditItem" method="post" action="Queue_PNR_BOM_action.cfm">
<CFOUTPUT QUERY="PNRBOMSearch" group="ItemID">
<tr>
<td>
#ECID_SPEC#
</td>
<td>
#APVID#
</td>
<CFOUTPUT group="APV_ItemID">
<td>
#APV_ItemID#
</td>
<td>
#Part_Number#
</td>
<CFOUTPUT>
<td align="center">
<cfif Approval_Initials Is Not "" and Document_Type EQ "PNR Req">
#Approval_Initials#
<cfelseif Approval_Initials Is "">
<select name="PNR_Approval_Initials#ItemID#">
<option value="">Select Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
<cfelseif Approval_Initials Is Not "" and Document_Type EQ "BOM Req">
#Approval_Initials#
<cfelseif Approval_Initials Is "">
<select name="BOM_Approval_Initials#ItemID#">
<option value="">Select Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
</td>
</cfif>
</cfoutput>
</cfoutput>
<!--- <td><input name="Open_Jobs_Affected#ItemID#" type="text" value="#Trim(Open_Jobs_Affected)#" size="30"></td> --->
</cfoutput>
</tr>
<tr>
<td colspan="4" align="center">
<input type="submit" value="Update">
<input type="reset" value="Reset"></td>
</tr>
</table>
<cfoutput>
<input type="hidden" name="listofids" value="#ValueList(PNRBOMSearch.ItemID)#">
</cfoutput>
</cfform>
Thanks again. I really appreciate all your help!
Andy
Copy link to clipboard
Copied
It is NOT a single IF statement.
In the PNR Column you would have an if statement to determine if the output needs to show existing initials OR a drop down box to set them.
In the DNR Column you would have another if statement to determine if the output needs to show existing initials OR a drop down box to set them.
Copy link to clipboard
Copied
Ilssac,
How do you do an OR statement? This is what I have below. It feels like it's really close now, but I just don't know how to do an Or.
<td align="center">
<cfif Approval_Initials Is Not "" and Document_Type EQ "PNR Req">
#Approval_Initials#
<cfelse>
<select name="PNR_Approval_Initials#ItemID#">
<option value="">Select Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
</cfif>
<cfif Approval_Initials Is Not "" and Document_Type EQ "BOM Req">
#Approval_Initials#
<cfelse>
<select name="BOM_Approval_Initials#ItemID#">
<option value="">Select Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
</cfif>
</td>
Andy
Copy link to clipboard
Copied
How does this code NOT fullfill your requirement?
Your code looks like it would do what I understand your requirements are.
When I said "OR" before, I was refering to the else, aka false, clause of the if conditional block, which your code show you utilizing.
But if you need an OR in your conditional statement you just use 'or' the same way you are using the 'and' conjuction.
Copy link to clipboard
Copied
Ilssac or Dan,
I have tried every possible way with If statements and Or's and And's and I still cannot get this to work exactly right. I think it's because in my database I have a column that says Document_Type. In this column I say whether or not that line item is a PNR Req or a BOM Req. But when I go to output it into a table on the web page, I want it displayed into 2 columns- 1 for PNR and 1 for BOM. I also want it so that if the initials are already in the database, then just output them, and if they aren't then output a drop down menu. I am really close to getting it to work correctly. I have it working so that both the PNR and BOM columns display the initials if they are filled in. I also have it working so that if there are no initials for that line item at all, then output drop down menus. Where I run into the problem is when I have a PNR Initial filled in, but there isn't a BOM initial filled in, and it should display a drop down menu to fill out the BOM initial. This doesn't work though because I have an If statement that says if the Document_Type equals PNR or BOM then output the initial (which it does under the PNR column for instance), else put the drop down. But since I have the Document_Type that says PNR Req for that line item already, it thinks it doesn't need to put the drop down under the BOM column, but I do need it there. I just don't know what else to try with this. Below is what I have for my code, but I just can't get the drop downs to show up in the BOM column if there is a PNR initial filled out already. I've tried keeping both columns separate in my code, but I can't because of the way the database is designed. I can also remove the TD tags, but I still have the same problem with the BOM drop down not showing up if there is a PNR initial in there already. Does this make any sense? Do you guys have any other ideas for me to try? Thanks.
<table width=*% align="center" cellspacing="0" cellpadding="4" border="0">
<tr>
<td><B>ECO</B> </td>
<!--- <td><B>ECO ItemID</B> </td> --->
<td><B>APVID</B> </td>
<td><B>APV ItemID</B></td>
<td><B>Part Number </B></td>
<td align="center"><B>PNR</B></td>
<td align="center"><B>BOM</B></td>
<!--- <td align="center"><B>Open Jobs Affected</B></td> --->
</tr>
<cfform name="EditItem" method="post" action="Queue_PNR_BOM_action.cfm">
<CFOUTPUT QUERY="PNRBOMSearch" group="ItemID">
<CFOUTPUT group="APV_ItemID">
<tr>
<td>
<cfif ECID is not "">
<a href="item_display.cfm?ECID=#ECID#">#ECID#</a>
<cfelse>
</cfif></td>
<td>
#APVID#
</td>
<td>
#APV_ItemID#
</td>
<td width="auto">
<cfif Part_Number Is Not "">
#Part_Number#
<cfelse>
</cfif></td>
<CFOUTPUT>
<cfif Document_Type EQ "PNR Req" or Document_Type EQ "BOM Req">
<td align="center">#Approval_Initials#</td>
<cfelseif Document_Type NEQ "PNR Req" or Document_Type NEQ "BOM Req">
<td align="center">
<select name="PNR_Approval_Initials#ItemID#">
<option value="">PNR Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
</td>
<td align="center">
<select name="BOM_Approval_Initials#ItemID#">
<option value="">BOM Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
</td>
</cfif>
</cfoutput>
</tr>
</cfoutput>
</cfoutput>
<tr>
<td colspan="4" align="center">
<input type="submit" value="Update">
<input type="reset" value="Reset"></td>
</tr>
</table>
<cfoutput>
<input type="hidden" name="listofids" value="#ValueList(PNRBOMSearch.ItemID)#">
</cfoutput>
</cfform>
andy
Copy link to clipboard
Copied
As best as I can understand. You have TWO INDEPENDENT requirements.
One to display PNR initials OR select control.
Two to display BOM initials OR select control.
I would expect that logic to look something like this.
<!--- DO I DISPLAY PNR INITIALS OR SELECT CONTROL --->
<cfif {conditions to disply PNR}>
DISPLAY PNR
<cfelse>
DISPLAY PNR SELECT
</cfif>
<!--- DO I DISPLY BOM INITIALS OR SELECT CONTROL --->
<cfif {conditions to display BOM}>
DISPLAY BOM
<cfelse>
DISPLAY BOM SELECT
</cfif>
You have not explained any reason it needs to be more complicated then that. I do not see why you are trying to do all of that with one overly complex if|elseif|else conditional statement.
Message was edited by: ilssac NOW there could be some challenge dealing with what ROW you are on when you are building your data. Because IIRC your PNR and BOM data are in different rows of the record set?
Copy link to clipboard
Copied
Ilssac,
If I just worry about the BOM column for right now and make it more simple and don't do anything with the PNR for now, you would think that an initial would be displayed if Document_Type equals "BOM Req" otherwise, display the drop down menu, but it doesn't. What it does is it displays both the drop down menu and the initial. Why is that? Is it because they are grouped or something? Here's what I did:
<cfif Document_Type EQ "BOM Req" and Approval_Initials is not "">
<td align="center">#Approval_Initials#</td>
<cfelse>
<td align="center">
<select name="BOM_Approval_Initials#ItemID#">
<option value="">BOM Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
</td>
</cfif>
Andy
Copy link to clipboard
Copied
jamie61880 wrote:
Is it because they are grouped or something?
Yes, exactly. Because that piece of your code is executed TWICE. Once for each row of the returned record set. So in one row there is a
BOM value so it is output. In the other row there is not a BOM value so the select control is output.
To see this add this bit of code to your output:
<cfif Document_Type EQ "BOM Req" and Approval_Initials is not "">
<td align="center">#currentRow# - #Approval_Initials#</td><cfelse>
<td align="center">
#currentRow# -
<select name="BOM_Approval_Initials#ItemID#">
<option value="">BOM Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
</td></cfif>
<cfif Document_Type EQ "BOM Req" and Approval_Initials is not "">
<td align="center">#Approval_Initials#</td><cfelse>
<td align="center">
<select name="BOM_Approval_Initials#ItemID#">
<option value="">BOM Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
</td></cfif>
You need to adjust your code to inspect BOTH rows. A couple of quick ideas that might help you out.
Check out the valueList() function. This function returns a list of ALL values in a column from a record list. You could then examin that list to see if there are any initials or not.
OR
IF your record set is ALWAYS exactly two rows, you can examin both rows by adding a row identify to your query reference.
That could look something like:
<cfif Document_Type EQ "BOM Req"
AND PNRBOMSearch.Approval_Initials[1] is not ""
AND PNRBOMSearch.Approval_Initials[2] is not "">
Copy link to clipboard
Copied
Ilssac,
I have tried both the Current Row function and the identify to my query reference, but they do not do anything different, unless I'm not writing it out correctly. I did the CurrentRow function exactly what you have below, but that did not do anything except put numbers with a dash next to each drop down menu. Do I need to set CurrentRow first or something? How do you use the CurrentRow function? What does it do? Here's what I did for identifying to my query reference:
<cfif Document_Type EQ "BOM Req" And PNRBOMSearch.Approval_Initials[1] is not ""
AND PNRBOMSearch.Approval_Initials[2] is not "">
<td align="center">#Approval_Initials#</td>
<cfelseif Document_Type EQ "BOM Req" And PNRBOMSearch.Approval_Initials[1] is ""
And PNRBOMSearch.Approval_Initials[2] is "">
<td align="center">
<select name="BOM_Approval_Initials#ItemID#">
<option value="">BOM Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
</td>
<cfelse>
<td align="center">
<select name="BOM_Approval_Initials#ItemID#">
<option value="">BOM Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
</td>
</cfif>
This code still outputs both the drop down and the initials next to each other.
I did find some code about using the Mod operator. It kind of worked, but only for my first record set and not the 2nd one. The 2nd one still displayed the drop down and the initials next to each other. Here's what I did with that below. I tried writing the same code with it eq 1 and that worked on the one that I have 1 row filled out, but then it didn't work for the ones where I had 2 rows filled out. I also tried writing another cfelseif statement with this code, but that didn't do anything.
<cfif Document_Type EQ "BOM Req" and Approval_Initials is not "">
<td align="center">#Approval_Initials#</td>
<cfelseif (PNRBOMSearch.CurrentRow mod 2 eq 0 AND NOT PNRBOMSearch.CurrentRow eq
PNRBOMSearch.RecordCount)>
<td align="center">
<select name="BOM_Approval_Initials#ItemID#">
<option value="">BOM Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
</td>
<cfelseif Approval_Initials is "">
<td align="center">
<select name="BOM_Approval_Initials#ItemID#">
<option value="">BOM Initials</option>
<cfloop query="ShowInitials">
<cfif Engineer_Initials EQ 1>
<option value="#Initials#">#Initials#</option>
</cfif>
</cfloop>
</select>
</td>
</cfif>
Andy
Copy link to clipboard
Copied
jamie61880 wrote:
I did the CurrentRow function exactly what you have below, but that did not do anything except put numbers with a dash next to each drop down menu.
That is all it was supposed to do. It was to show you which ROW was generating which output.
I then went on to give you a couple of different options to handle the multi-row problem.
Copy link to clipboard
Copied
This is how I had to combine 2 rows into 1 with dynamic data:
<CFQUERY NAME="PNRBOMSearch" Datasource="#application.DataSource#">
SELECT ECID, Requested_By_Initials, EC_Completion_Initials, EC_Completion_Date, Comments, ItemID, ECID_SPEC, ECO_Start_Date, Date_Requested, Part_Number, Description, P_Drive_Docs, Release_Status, Validation_ItemID, Validation_ECID, Validation_Qty, Open_Jobs_Affected,
Approval_PNR.APVID as PNR_APVID, Approval_BOM.APVID as BOM_APVID,
Approval_PNR.Approval_Initials as PNR_Initials, Approval_BOM.Approval_Initials as BOM_Initials
FROM ((((ECO_Master LEFT JOIN ECO_Items ON ECO_Master.ECID = ECO_Items.ECID_SPEC)
LEFT JOIN Validation_Records ON ECO_Items.ItemID = Validation_Records.Validation_ItemID)
LEFT JOIN Approval as Approval_PNR ON (ECO_Items.ItemID = Approval_PNR.APV_ItemID AND Approval_PNR.Document_Type = 'PNR Req'))
LEFT JOIN Approval as Approval_BOM ON (ECO_Items.ItemID = Approval_BOM.APV_ItemID AND Approval_BOM.Document_Type = 'BOM Req'))
WHERE (Requested_By_Initials = '#cookie.UserInitials#' AND EC_Completion_Date Is Null)
ORDER BY ECID ASC, ItemID ASC
</CFQUERY>
Andy
Copy link to clipboard
Copied
You do "or" statements like this:
<cfif condition1 or condition2 etc>
do something
<cfelse>
do something else
</cfif>
The syntax is the simple part. Knowing what you want to do is harder.