displaying previously entered multiple fields | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| |
Hey Everyone,
Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place.
what i am trying to display previously entered multiple fields. I am able to get my serial fields to display correctly, but i can not display my parts fields correctly.
Currently this is what it does
serial information 1
parts 1
parts 2
serial information 2
parts 1
parts 2
and what it needs to do
serial information 1
parts 1
serial information 2
parts 1
the problem is instead of the part going with the correct serial. it basically puts the information for both parts i added under both of the 2 serials I am also having trouble deleting fields an adding fields for the parts fields.
if someone could explain what i am doing wrong with the parts i would really appreciate it. I know it has to do with the count, just not sure what i am doing wrong
here is the javascript for serial and parts that allows me to add serials and parts
here is the html/coldfusion that displays what was previously entered for serials and parts.
Thank you in advance,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Does the query for parts only get the parts for the current serial? Show the code for the cfquery.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Does the query for parts only get the parts for the current serial? Show the code for the cfquery. Hey Acoder,
well the parts is getting the correct information for that ticket an so is the serial. Its just repeating the results instead of the correct part going under the correct serial. But here is the cfquery
for serial - <!---Shows what was previously entered into serial and description table--->
-
<cfquery name="serial" datasource="CustomerSupport">
-
SELECT pka_serialNo,pkb_fk_ticketNo,model_no,product_type,software_hardware,
-
resolution,resolution_date,verification_date,rma_data,type_hardware_failure,
-
dept_responsibility,resolution_verified_by,fk_serialNo,fk_ticketNo,description
-
FROM dbo.tbl_CS_serial
-
LEFT JOIN dbo.tbl_CS_notes_descr
-
ON dbo.tbl_CS_serial.pkb_fk_ticketNo=dbo.tbl_CS_notes_descr.fk_ticketNo and
-
dbo.tbl_CS_serial.pka_serialNo=dbo.tbl_CS_notes_descr.fk_serialNo
-
WHERE pkb_fk_ticketNo = #URL.pk_ticketID# and fk_ticketNo = #URL.pk_ticketID#
-
ORDER BY pkb_fk_ticketNo
-
</cfquery>
for parts - <!---Shows what was previously entered into parts table--->
-
<cfquery name="parts" datasource="CustomerSupport">
-
SELECT pk_partID,fk_serialNo,fk_ticketNo,hc_partNo,ltrim(rtrim(part_returned)) as part_returned,defective,submission
-
FROM dbo.tbl_CS_parts
-
WHERE fk_ticketNo = #URL.pk_ticketID#
-
</cfquery>
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
You don't want all the parts at once. You want parts for each serial separately. To avoid creating a separate query for each, get all the parts and then use a query of queries to get parts for each serial separately.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder You don't want all the parts at once. You want parts for each serial separately. To avoid creating a separate query for each, get all the parts and then use a query of queries to get parts for each serial separately. Hey Acoder,
Well how would create a query of queries to get the parts?
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Use the current query and then instead of querying the database, you query the query. To do that, set the dbtype attribute of cfquery to "query". See Query of Queries | | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Use the current query and then instead of querying the database, you query the query. To do that, set the dbtype attribute of cfquery to "query". See Query of Queries Hey Acoder,
Is this all i need to do to it. I read over your link but i am still a bit confused. - <!---Shows what was previously entered into parts table--->
-
<cfquery name="parts" datasource="CustomerSupport" dbtype="query">
-
SELECT pk_partID,fk_serialNo,fk_ticketNo,hc_partNo,ltrim(rtrim(part_returned)) as part_returned,defective,submission
-
FROM dbo.tbl_CS_parts
-
WHERE fk_ticketNo = #URL.pk_ticketID#
-
</cfquery>
-
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Well, to be honest, you don't necessarily need a query of queries. However, if you're looking at performance benefits and efficiency, it makes sense. We can carry on down this route, but if you feel that you just want to get it working without looking at some new type of coding, then we can look at the inefficient solution.
Your query of queries should query the parts query, not the database and you can just select * because you already have only the fields that you need.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Well, to be honest, you don't necessarily need a query of queries. However, if you're looking at performance benefits and efficiency, it makes sense. We can carry on down this route, but if you feel that you just want to get it working without looking at some new type of coding, then we can look at the inefficient solution.
Your query of queries should query the parts query, not the database and you can just select * because you already have only the fields that you need. Hey Acoder,
Well the faster the better so i guess we can stick with what we are doing. But here is what i have now. I looked at the example better an think i understand a bit more. The one part i am confused on is what would i put for cfqueryparam. Would i put what i had before which is the pk_ticketID? - <cfquery name="parts" dbtype="query" >
-
SELECT *
-
FROM dbo.tbl_CS_parts
-
WHERE fk_ticketNo <cfqueryparam value="#LastNameSearch#"
-
cfsqltype="cf_sql_char" maxLength="20">
-
</cfquery>
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Replace lastnamesearch with serial number (the field name from the serial query).
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Replace lastnamesearch with serial number (the field name from the serial query). Hey Acoder,
Do i replace the lastnamesearch with the serial number field from the serial table or the serial number field from the parts table? both tables have a serial field and both contain the same serial number. Right now i am using the serial field from parts table. - <cfquery name="parts" dbtype="query" >
-
SELECT *
-
FROM dbo.tbl_CS_parts
-
WHERE fk_ticketNo <cfqueryparam value="#fk_serialNo#"
-
cfsqltype="cf_sql_char" maxLength="20">
-
</cfquery>
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
It should be the field from the serial query. Also change the FROM clause to the name of the query that selects all parts. If it's parts, don't use the same name to name this particular query.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder It should be the field from the serial query. Also change the FROM clause to the name of the query that selects all parts. If it's parts, don't use the same name to name this particular query. Hey Acoder,
Here is what i did, not sure if i did it right. - <cfquery name="getparts" dbtype="query" >
-
SELECT *
-
FROM dbo.tbl_CS_parts
-
WHERE fk_ticketNo <cfqueryparam value="#pka_serialNo#"
-
cfsqltype="cf_sql_char" maxLength="20">
-
</cfquery>
-
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
It should query "parts" (name of the first query), not dbo... and shouldn't the field being checked in the WHERE clause be fk_serialno? You also forgot an =.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder It should query "parts" (name of the first query), not dbo... and shouldn't the field being checked in the WHERE clause be fk_serialno? You also forgot an =. Hey Acoder,
Yes you are right it should be fk_serialNo. An i been thinking the whole we only needed the one parts my bad. Ok so the whole thing should be the following - <!---Shows what was previously entered into parts table--->
-
<cfquery name="parts" datasource="CustomerSupport">
-
SELECT pk_partID,fk_serialNo,fk_ticketNo,hc_partNo,ltrim(rtrim(part_returned)) as part_returned,defective,submission
-
FROM dbo.tbl_CS_parts
-
WHERE fk_ticketNo = #URL.pk_ticketID#
-
</cfquery>
-
-
<cfquery name="getparts" dbtype="query" >
-
SELECT *
-
FROM dbo.tbl_CS_parts
-
WHERE fk_serialNo=<cfqueryparam value="#pka_serialNo#"
-
cfsqltype="cf_sql_char" maxLength="20">
-
</cfquery>
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Now this getparts query should be after the serial display and before the parts output and you would loop this query.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Now this getparts query should be after the serial display and before the parts output and you would loop this query. Hey Acoder,
So would i just put a loop around the getparts query an then would it be like
<cfloop from="" to=""> or a different type of loop? an if it is this type of loop what would i put in from and to? but here is what i have - <!---Shows what was previously entered into serial and description table--->
-
<cfquery name="serial" datasource="CustomerSupport">
-
SELECT pka_serialNo,pkb_fk_ticketNo,model_no,product_type,software_hardware,
-
resolution,resolution_date,verification_date,rma_data,type_hardware_failure,
-
dept_responsibility,resolution_verified_by,fk_serialNo,fk_ticketNo,description
-
FROM dbo.tbl_CS_serial
-
LEFT JOIN dbo.tbl_CS_notes_descr
-
ON dbo.tbl_CS_serial.pkb_fk_ticketNo=dbo.tbl_CS_notes_descr.fk_ticketNo and
-
dbo.tbl_CS_serial.pka_serialNo=dbo.tbl_CS_notes_descr.fk_serialNo
-
WHERE pkb_fk_ticketNo = #URL.pk_ticketID# and fk_ticketNo = #URL.pk_ticketID#
-
ORDER BY pkb_fk_ticketNo
-
</cfquery>
-
-
<!---Shows what was previously entered into parts table--->
-
<!---dbtype="query"--->
-
<cfquery name="getparts" dbtype="query" >
-
SELECT *
-
FROM dbo.tbl_CS_parts
-
WHERE fk_serialNo=<cfqueryparam value="#pka_serialNo#"
-
cfsqltype="cf_sql_char" maxLength="20">
-
</cfquery>
-
-
<!---Shows what was previously entered into parts table--->
-
<cfquery name="parts" datasource="CustomerSupport">
-
SELECT pk_partID,fk_serialNo,fk_ticketNo,hc_partNo,ltrim( rtrim(part_returned)) as part_returned,defective,submission
-
FROM dbo.tbl_CS_parts
-
WHERE fk_ticketNo = #URL.pk_ticketID#
-
</cfquery>
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
The FROM clause of the getparts query should be using the "parts" query, not referring to the database/table names in the database.
It should also appear after the parts query. Looping would be the normal loop over a query as you're already doing.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder The FROM clause of the getparts query should be using the "parts" query, not referring to the database/table names in the database.
It should also appear after the parts query. Looping would be the normal loop over a query as you're already doing. Hey Acoder,
So would this be correct? - <!---Shows what was previously entered into serial and description table--->
-
<cfquery name="serial" datasource="CustomerSupport">
-
SELECT pka_serialNo,pkb_fk_ticketNo,model_no,product_type,software_hardware,
-
resolution,resolution_date,verification_date,rma_data,type_hardware_failure,
-
dept_responsibility,resolution_verified_by,fk_serialNo,fk_ticketNo,description
-
FROM dbo.tbl_CS_serial
-
LEFT JOIN dbo.tbl_CS_notes_descr
-
ON dbo.tbl_CS_serial.pkb_fk_ticketNo=dbo.tbl_CS_notes_descr.fk_ticketNo and
-
dbo.tbl_CS_serial.pka_serialNo=dbo.tbl_CS_notes_descr.fk_serialNo
-
WHERE pkb_fk_ticketNo = #URL.pk_ticketID# and fk_ticketNo = #URL.pk_ticketID#
-
ORDER BY pkb_fk_ticketNo
-
</cfquery>
-
-
<!---Shows what was previously entered into parts table--->
-
<!---dbtype="query"--->
-
<cfquery name="getparts" dbtype="query" >
-
SELECT *
-
FROM parts
-
WHERE fk_serialNo=<cfqueryparam value="#pka_serialNo#"
-
cfsqltype="cf_sql_char" maxLength="20">
-
</cfquery>
-
-
<!---Shows what was previously entered into parts table--->
-
<cfquery name="parts" datasource="CustomerSupport">
-
SELECT pk_partID,fk_serialNo,fk_ticketNo,hc_partNo,ltrim( rtrim(part_returned)) as part_returned,defective,submission
-
FROM dbo.tbl_CS_parts
-
WHERE fk_ticketNo = #URL.pk_ticketID#
-
</cfquery>
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
The parts query can remain where it is, but you need to move the getparts query to where the parts are displayed. Also the cfloop on line 196 (post #1) should now be over "getparts", not parts.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder The parts query can remain where it is, but you need to move the getparts query to where the parts are displayed. Also the cfloop on line 196 (post #1) should now be over "getparts", not parts. Hey Acoder,
When i move the cfloop. Do i need to include the count that i had around the cfloop or just take it out?
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
You don't need to move the loop. Just replace "parts" with "getparts".
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder You don't need to move the loop. Just replace "parts" with "getparts". Hey Acoder,
When i go to view one i previously submitted i am getting the error
Error resolving parameter PKA_SERIALNO
ColdFusion was unable to determine the value of the parameter
here is what i have - <!---Shows what was previously entered into serial and description table--->
-
<cfquery name="serial" datasource="CustomerSupport">
-
SELECT pka_serialNo,pkb_fk_ticketNo,model_no,product_type,software_hardware,
-
resolution,resolution_date,verification_date,rma_data,type_hardware_failure,
-
dept_responsibility,resolution_verified_by,fk_serialNo,fk_ticketNo,description
-
FROM dbo.tbl_CS_serial
-
LEFT JOIN dbo.tbl_CS_notes_descr
-
ON dbo.tbl_CS_serial.pkb_fk_ticketNo=dbo.tbl_CS_notes_descr.fk_ticketNo and
-
dbo.tbl_CS_serial.pka_serialNo=dbo.tbl_CS_notes_descr.fk_serialNo
-
WHERE pkb_fk_ticketNo = #URL.pk_ticketID# and fk_ticketNo = #URL.pk_ticketID#
-
ORDER BY pkb_fk_ticketNo
-
</cfquery>
-
-
<!---Shows what was previously entered into parts table--->
-
<cfquery name="parts" datasource="CustomerSupport">
-
SELECT pk_partID,fk_serialNo,fk_ticketNo,hc_partNo,ltrim( rtrim(part_returned)) as part_returned,defective,submission
-
FROM dbo.tbl_CS_parts
-
WHERE fk_ticketNo = #URL.pk_ticketID#
-
</cfquery>
-
-
<!---Shows what was previously entered into parts table--->
-
<!---dbtype="query"--->
-
<cfquery name="getparts" dbtype="query" >
-
SELECT *
-
FROM parts
-
WHERE fk_serialNo=<cfqueryparam value="#pka_serialNo#"
-
cfsqltype="cf_sql_char" maxLength="20">
-
</cfquery>
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
That's because pka_serialNo hasn't been set yet. That query (getparts) needs to be moved to where the second inner cfloop is.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder That's because pka_serialNo hasn't been set yet. That query (getparts) needs to be moved to where the second inner cfloop is. Hey Acoder,
you saying something like this?
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
I'm not sure why you've moved it there (line 13). It needed to stay where it was (line 196/7), but just changed to what it is now ("getparts").
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder I'm not sure why you've moved it there (line 13). It needed to stay where it was (line 196/7), but just changed to what it is now ("getparts"). Hey Acoder,
Here is what i have in full
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
The getparts query should be just before the loop where it's used.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder The getparts query should be just before the loop where it's used. Hey Acoder,
That is working beautifully. The only thing i can not get working is adding parts and deleting parts. With the deleteing parts when we go an insert it we had deleting set to partIdName and i tried to change it from that to part#count1#Nameserialno but that don't seem to work. An tried to change the add part from divIdName to dynamic#count#Input. But cant seem to get it right. Here is what is in the html
an here is the javascript
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
For the add/delete functionality to work, you need to make sure the counts match up. So if there are three, the count has to be 3 and the divs IDs/field names all have to be correct. Check the add functions to see how the naming works and make sure the display from Coldfusion is the same.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder For the add/delete functionality to work, you need to make sure the counts match up. So if there are three, the count has to be 3 and the divs IDs/field names all have to be correct. Check the add functions to see how the naming works and make sure the display from Coldfusion is the same. Hey Acoder,
I get what your saying. I got it removing and adding. But the parts is not counting right.Right now i am testing it on 2 serials both with a part applied to it. An the first serial with the first part counts correctly. But the second part with the second serial does not. It counts 1 an then it goes to 3, no 2 in between. Here is what i have.
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Where you're setting the ID: "part#count1#Name#count1#" it should be #count# for one of them. If you remember, it uses the parts count and the serial count.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Where you're setting the ID: "part#count1#Name#count1#" it should be #count# for one of them. If you remember, it uses the parts count and the serial count. Hey Acoder,
So this one would be correct right? - <div id="part#count1#Name#count#">
i looked and compared the insert to the edit. An the only thing different i can see is when you look at dynamic 2 in my insert it does this - <input id="partscount2" type="hidden" value="1" name="partscount2"/>
-
<input id="serialcount" type="hidden" value="2" name="serialcount"/>
and in my edit it does this - <input id="partscount2" type="hidden" value="2" name="partscount2"/>
-
<input id="serialcount" type="hidden" value="2" name="serialcount"/>
also noticed if you look at the first dynamic input and look at the add parts and remove serial it says this
this is what it looks like for creating - <input class="removeticket" type="button" onclick="removeElement('dynamic1Input')" value="Remove Serial "1""/>
-
</td>
-
</tr>
-
<tr>
-
<td>
-
<input class="addticket" type="button" onclick="addpartInput('dynamic1Input')" value="Add Parts"/>
an this is what it looks like in edit - <input class="removeticket" type="button" onclick="removeElement('dynamic1Input')" value="Remove Serial 1"/>
-
</td>
-
</tr>
-
<tr>
-
<td>
-
<input class="addticket" type="button" onclick="addpartInput('dynamic0Input')" value="Add Parts"/>
do i need to create another count in the serial section so that adding parts will act right?
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
No, just make sure that #count# is always used for serial counting and #count1# for parts counting.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields
Hey Acoder,
I figured it out. This line needed to be in the parts div instead of the serial div. - <input type="hidden" name="partscount#count#" id="partscount#count#" value="#count1#">
but i have now ran into another problem with the inserting. When i was testing it. I accidentally deleted one of the parts an so instead of parts 1 parts 2 parts 3 i had
parts 1 parts 3 an when i submitted i got the following error
Error Diagnostic Information
An error occurred while evaluating the expression:
hcpn = Form["hcpn_" & ps & "_#machinecount#"]
Error near line 96, column 8.
--------------------------------------------------------------------------------
The member "HCPN_3_2" in dimension 1 of object "Form" cannot be found. Please, modify the member name.
is there anyway for it to make it work where if a user deleted one it will still keep going. The serial one was able to work even if i user deleted the 2 out of it.
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Ah, it seems it's using one count for all parts instead of a separate count for each set of parts in a particular serial. Make sure you have separate counts.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Ah, it seems it's using one count for all parts instead of a separate count for each set of parts in a particular serial. Make sure you have separate counts. Hey Acoder,
yeah i figured out its problem wanted the hidden parts count in the parts section. an forgot to add the count for serial behind each field (like we did in the parts section of javascript).But now i am having problems with the insert of parts again see above.
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Well done. I guess I replied too early ;)
As for the new problem, to solve it, you could copy the values from the later parts to the deleted part and above and delete the last one. Do you see how that would work?
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Well done. I guess I replied too early ;)
As for the new problem, to solve it, you could copy the values from the later parts to the deleted part and above and delete the last one. Do you see how that would work? Hey Acoder,
You definately lost me on that one. An the thing is the user might add for example 5 parts an delete 2 and 4 an then it be 1,3,and 5 left. So i don't know if just deleting the last one would work.An i just noticed something else (sigh) but when i didn't add any parts and added 2 serials an clicked submit it brought up the error
An error occurred while evaluating the expression:
hcpn = Form["hcpn_" & ps & "_#machinecount#"]
Error near line 96, column 8.
--------------------------------------------------------------------------------
The member "HCPN_1_1" in dimension 1 of object "Form" cannot be found. Please, modify the member name.
an sadly thats not good either cause sometimes the user might not add any parts. Any ideas?
Thank you :),
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Let me explain how that would work with an example. If you have five parts and want to delete no.2 and move 3 to 2, 4 to 3 and 5 to 4 then delete the last one, all the parts will be intact and no. 2 will be removed. That may seem a lot of work, but with a loop it's not as much as you think.
That's one option. Another option is to store the numbers of the parts and delete part numbers from that field. You can use the field value in place of a count because it would be a list and you can use listlen to get the count. This would probably be the easier solution.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Let me explain how that would work with an example. If you have five parts and want to delete no.2 and move 3 to 2, 4 to 3 and 5 to 4 then delete the last one, all the parts will be intact and no. 2 will be removed. That may seem a lot of work, but with a loop it's not as much as you think.
That's one option. Another option is to store the numbers of the parts and delete part numbers from that field. You can use the field value in place of a count because it would be a list and you can use listlen to get the count. This would probably be the easier solution. Hey Acoder,
Well whatever way you think would be the best way. The only thing with the first suggestion i am worried about is this. What if they delete 2 fields. Instead of just no 2, lets say we have 5 total fields an we delete 2 and 4 then would all the remaining fields become 1, 2 and 3 or would it remain like 1,2,3,5? mostly what i am worried about is them deleting more then one field. But whatever way you think would be best then lets start with that.
Thank you :),
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
That shouldn't be a problem because only one part would be deleted at a time.
I think, however, that the second solution may make more sense here (even though it would involve changing some of the code that does the inserting). The advantage of the first approach is that you only need to change in one place. The second method seems easier though.
Is it necessary that part numbers should go from 1 to, say, 3 instead of having gaps?
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder That shouldn't be a problem because only one part would be deleted at a time.
I think, however, that the second solution may make more sense here (even though it would involve changing some of the code that does the inserting). The advantage of the first approach is that you only need to change in one place. The second method seems easier though.
Is it necessary that part numbers should go from 1 to, say, 3 instead of having gaps? Hey Acoder,
Well the thing is if it has gaps, is when it runs into problems. When i inserted parts 1, and parts 3. It was going we can't find 2 and can not insert into the database.It basically has a fit when its missing a number.
I also i got another problem i wanted to ask on. I ran into the problem where i didn't select any parts at all to upload and got the same error i got for not upload the parts in order saying - An error occurred while evaluating the expression:
-
-
-
hcpn = Form["hcpn_" & ps & "_#machinecount#"]
-
-
-
Error near line 96, column 8.
-
--------------------------------------------------------------------------------
-
-
The member "HCPN_1_1" in dimension 1 of object "Form" cannot be found. Please, modify the member name
is there a way to make it not insert a part if a part was not selected?
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
I understand that, but I meant gaps in the numbering for display, e.g. would it be a problem to have part 1 displayed, then part 3 when adding/deleting parts? Of course, this would be academic when you get round to displaying later which will be sorted out.
For no parts, you can validate based on the count.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder I understand that, but I meant gaps in the numbering for display, e.g. would it be a problem to have part 1 displayed, then part 3 when adding/deleting parts? Of course, this would be academic when you get round to displaying later which will be sorted out.
For no parts, you can validate based on the count. Hey Acoder,
Based on what i know i don't think it would be a problem as long as it wouldn't affect how it displayed back later Because how it displays back doesn't have to be parts 1, parts 3. It can just be parts 1 parts 2. But how would i validate the count?
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Actually, I don't think you should need to validate the count if your loop has been written correctly and the count is correct. What code do you have currently for inserting parts?
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Actually, I don't think you should need to validate the count if your loop has been written correctly and the count is correct. What code do you have currently for inserting parts? Hey Acoder,
Here is what i have for inserting
and here is what i have when i submit the form. was not sure if you wanted this but thought i would include it just in case - <!---Inserts information into serial table.--->
-
<CFIF REQUEST_METHOD EQ "POST">
-
<CFSET machineListLen = listLen(Form.serialcount)>
-
<CFLOOP from="1" to="#machineListLen#" index="machineCount">
-
<CFSET serialnum = Form["serialnum_" & machineCount]>
-
<CFSET modelno = Form["modelno_" & machineCount]>
-
<CFSET producttype = Form["producttype_" & machineCount]>
-
<CFSET softhardware = Form["softhardware_" & machineCount]>
-
<CFSET resolution = Form["resolution_" & machineCount]>
-
<CFSET resdate = Form["resdate_" & machineCount]>
-
<CFSET resvertified = Form["resvertified_" & machineCount]>
-
<CFSET vertifidate = Form["vertifidate_" & machineCount]>
-
<CFSET deptvendor = Form["deptvendor_" & machinecount]>
-
<CFSET hardwarefailure = Form["hardwarefailure_" & machineCount]>
-
<CFSET rma = Form["rma_" & machineCount]>
-
<CFSET thedescription = Form["thedescription_" & machineCount]>
-
<!--- <CFSET followdate = Form["followdate_" & machineCount]>
-
<CFSET onsite = Form["onsite_" & machineCount]>
-
<CFSET numonsite = Form["numonsite_" & machineCount]>--->
-
-
<!--- inserts information into the serial table--->
-
<cfquery name="serial" datasource="CustomerSupport">
-
exec usp_CS_Insertserial
-
<cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
-
'#Form.ID#',
-
<cfqueryparam value="#modelno#" CFSQLType = "CF_SQL_VARCHAR">,
-
<cfqueryparam value="#producttype#" CFSQLType = "CF_SQL_VARCHAR">,
-
<cfqueryparam value="#softhardware#" CFSQLType = "CF_SQL_VARCHAR">,
-
<cfqueryparam value="#resolution#" CFSQLType = "CF_SQL_VARCHAR">,
-
<cfqueryparam value="#resdate#">,
-
<cfqueryparam value="#resvertified#" CFSQLType = "CF_SQL_VARCHAR">,
-
<cfqueryparam value="#vertifidate#">,
-
<cfqueryparam value="#deptvendor#" CFSQLType = "CF_SQL_VARCHAR">,
-
<cfqueryparam value="#hardwarefailure#" CFSQLType = "CF_SQL_VARCHAR">,
-
<cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">
-
</cfquery>
-
-
<!---Inserts information into notes_descr table.--->
-
<cfquery name="description" datasource="CustomerSupport">
-
exec usp_CS_Insertdescription
-
<cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
-
'#Form.ID#',
-
<cfqueryparam value="#thedescription#" CFSQLType = "CF_SQL_VARCHAR">,
-
'#Form.fk_addedBy#'
-
</cfquery>
-
-
-
<!---Inserts parts information into parts table.--->
-
<!---because it is a bit we don't use 'ticks' around defective for parts table--->
-
<cfloop from="1" to="#form['partscount' & machinecount]#" index="ps">
-
<cfparam name="Form.defective_#ps#_#machinecount#" default="0">
-
<cfparam name="Form.partsreturn_#ps#_#machinecount#" default="0">
-
<CFSET hcpn = Form["hcpn_" & ps & "_#machinecount#"]>
-
<CFSET partsreturn = Form["partsreturn_" & ps & "_#machinecount#"]>
-
<CFSET defective = Form["defective_" & ps & "_#machinecount#"]>
-
<cfquery name="parts" datasource="CustomerSupport">
-
exec usp_CS_Insertparts
-
<cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
-
'#Form.ID#',
-
<cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
-
<cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
-
<cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">,
-
'#Form.submission#'
-
</cfquery>
-
</cfloop>
-
</CFLOOP>
-
</CFIF>
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
It was actually the Coldfusion code I was looking for. See this line: - <cfloop from="1" to="#form['partscount' & machinecount]#" index="ps">
If the parts count is 0, then there's no loop. Make sure the count is 0 when there are no parts.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder It was actually the Coldfusion code I was looking for. See this line: - <cfloop from="1" to="#form['partscount' & machinecount]#" index="ps">
If the parts count is 0, then there's no loop. Make sure the count is 0 when there are no parts. Hey Acoder,
Well that makes perfect since :). But ok so how do we make it so that parts count or not count missing parts?
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Does this problem occur when no parts have been added at all or when you add a part and then delete it (leaving no parts)?
|  | | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,501 network members.
|