Hey Everyone,
Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also the parts section an i seem to be having trouble.
When i try to insert into the parts section i get the error Invalid character value for cast specification. But not sure what i am doing wrong. Here is what i am using to insert. All the sections below work except the.Inserts parts information into parts table section. - <!---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 hcpn = Form["hcpn_" & machineCount]>
-
<CFSET partsreturn = Form["partsreturn_" & machineCount]>
-
<CFSET defective = Form["defective_" & machineCount]>
-
<!--- <CFSET followdate = Form["followdate_" & machineCount]>
-
<CFSET onsite = Form["onsite_" & machineCount]>
-
<CFSET numonsite = Form["numonsite_" & machineCount]>--->
-
-
<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--->
-
<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">
-
<!--- <cfquery param value="#submission#" CFSQLType = "CF_SQL_VARCHAR">--->
-
</cfquery>
-
-
</CFLOOP>
-
</CFIF>
-
here is the multiple fields section in my form for the serial section.
here is the multiple field section for the parts section - <!---Allows us to add PARTS information multiple times--->
-
<script type="text/javascript">
-
<!---Adds multiple fields for parts --->
-
function addpartInput(partName){
-
var parts = document.getElementById(partName);
-
var getparts = document.getElementById('div');
-
var serialno = partName.replace("dynamic","").replace("Input","");
-
var avalue = document.getElementById("partscount"+serialno);
-
var count = parseInt(avalue.value) + 1;
-
avalue.value = count;
-
var partdiv = document.createElement('div');
-
var partIdName = 'part' + count + 'Name' + serialno;
-
-
partdiv.setAttribute('id',partIdName);
-
-
<!--- Adds Extra fields for parts table --->
-
partdiv.innerHTML =
-
<!---what used originally for this tableclass='createticketables' id='spaceup'--->
-
"<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0' >" +
-
"<th class='sectiontitle' colspan='7'>Parts Information "+ count +" Serial Information "+serialno+"</th>" +
-
"<tr>" +
-
"<td class='indent' id='formfieldpadding'>HC P/N: <input type='text' name='hcpn_" + count + "' style='margin:0px'></td>" +
-
"<td class='red'>" +
-
"Parts been returned* " +
-
"<input type='checkbox' name='partsreturn_" + count +"' value='1'/>" +
-
"</td>" +
-
"<td>" +
-
"<td class='indent'>Defective<input type='checkbox' name='defective_" + count +"' value='1'/></td>" +
-
"</td>" +
-
"</tr>" +
-
"</table>" +
-
"<table table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0' >" +
-
"<tr>" +
-
"<td class='indent' id='formfieldpadding'>Follow up Date:(MM/DD/YYYY) " +
-
"<input type='text' name='followdate_" + count + "' value='' size='8'/> " +
-
"Current Date<input type='checkbox' name='followcheck_"+ count +"' value='' onClick='followdate.value=fill_date()'/></td>" +
-
"<td>On Site:</td>" +
-
"<td><select name='onsite_" + count +"'>" +
-
"<option value='No Choice' selected>No Choice</option>" +
-
"<option value='Yes'>Yes</option>" +
-
"<option value='No'>No</option>" +
-
"</select><td>" +
-
"<td># of Onsite:</td><td><select name='numonsite_" + count +"'>" +
-
"<option value='' selected>No Choice</option>" +
-
"<cfloop from='0' to='10' index='nonsite'><cfoutput>" +
-
"<option value='#nonsite#'>#nonsite#</option></cfoutput></cfloop>" +
-
"</select><td>" +
-
"</tr>" +
-
"</table>" +
-
<!---"<input type='hidden' value='0' id='aValue' />" +--->
-
"<input type='hidden' name='serialcount' value='" + count + "'>";
-
-
-
<!--- Adds Delete to every ticket --->
-
partdiv.innerHTML = partdiv.innerHTML +
-
"<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0'>" +
-
"<tr>" +
-
"<td>" +
-
"<input type='button' class='removeticket' value='Remove Parts ""+count +""' onclick=\"removetheElement(\'"+partIdName+"\')\"></a>" +
-
"</td>" +
-
"</td>" +
-
"</tr>" +
-
"</table>";
-
-
document.getElementById(partName).appendChild(partdiv);
-
}
-
-
<!---Allows us to remove multiple fields--->
-
function removetheElement(divNum) {
-
var d = document.getElementById('partsInput');
-
var olddiv = document.getElementById(divNum);
-
olddiv.parentNode.removeChild(olddiv);
-
}
-
-
</script>
Thank you in advance,
Rach
58 8014 acoder 16,027
Recognized Expert Moderator MVP
Since you can have multiple parts per serial, you need to use the part-counts in each serial to loop over (as you've done with serial-count) to add parts to each serial.
Since you can have multiple parts per serial, you need to use the part-counts in each serial to loop over (as you've done with serial-count) to add parts to each serial.
Hey Acoder,
So would something like this work?
used for serial and description - <!---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]>--->
-
-
<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>
-
</CFLOOP>
-
</CFIF>
-
used for the parts section - <!---Inserts parts information into parts table.--->
-
<!---because it is a bit we don't use 'ticks' around defective for parts table--->
-
<CFIF REQUEST_METHOD EQ "POST">
-
<CFSET machineListLen = listLen(Form.partscount)>
-
<CFLOOP from="1" to="#machineListLen#" index="machineCount">
-
<CFSET hcpn = Form["hcpn_" & machineCount]>
-
<CFSET partsreturn = Form["partsreturn_" & machineCount]>
-
<CFSET defective = Form["defective_" & 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">
-
<!--- <cfquery param value="#submission#" CFSQLType = "CF_SQL_VARCHAR">--->
-
</cfquery>
-
</CFLOOP>
-
</CFIF>
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
That wouldn't necessarily work because there are multiple counts for parts, so you would need to get each parts count and loop over that number of times for each serial.
That wouldn't necessarily work because there are multiple counts for parts, so you would need to get each parts count and loop over that number of times for each serial.
Hey Acoder,
I hate to say it but i am completely lost by what you mean. This is how i have it right now - <!---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 hcpn = Form["hcpn_" & machineCount]>
-
<CFSET partsreturn = Form["partsreturn_" & machineCount]>
-
<CFSET defective = Form["defective_" & machineCount]>
-
<!--- <CFSET followdate = Form["followdate_" & machineCount]>
-
<CFSET onsite = Form["onsite_" & machineCount]>
-
<CFSET numonsite = Form["numonsite_" & machineCount]>--->
-
-
<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--->
-
<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">
-
<!--- <cfquery param value="#submission#" CFSQLType = "CF_SQL_VARCHAR">--->
-
</cfquery>
-
</CFLOOP>
-
</CFIF>
Are you saying to do 2 cfloops one for serial (Iike i have now) an then add another cfloop for parts? would i then only put it around the parts section or all of the code like above? just confused on what i need to get
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
Yes, two cfloops and the second one only around parts looping from 1 to partscount1,2,3,etc. where 1,2,3 would be the current serial count.
Yes, two cfloops and the second one only around parts looping from 1 to partscount1,2,3,etc. where 1,2,3 would be the current serial count.
Hey Acoder,
so would i do the loop like this? was not sure what to put in to=. - <cfloop from="1" to="partc">
-
<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">
-
<!--- <cfquery param value="#submission#" CFSQLType = "CF_SQL_VARCHAR">--->
-
</cfquery>
-
</cfloop>
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
The "to" attribute would need to be set to the parts count variables, e.g. #partscount# where #partscount# could be set in the line before to the form variable passed from the client-side.
The "to" attribute would need to be set to the parts count variables, e.g. #partscount# where #partscount# could be set in the line before to the form variable passed from the client-side.
Hey Acoder,
Ok i am lost in my serial function i have this line - "<input type='hidden' value='0' id='"+partc+"' \>" +
do i need to give this line a name an then put whatever the name i put for this line in the "to" for the cfloop?
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
Yes, it also needs a name. Note that partc is not the ID/name - it's the variable holding the string value which you set earlier in the function.
Yes, it also needs a name. Note that partc is not the ID/name - it's the variable holding the string value which you set earlier in the function.
Hey Acoder,
Ok so like this - "<input type='hidden' value='0' name="partscount" id="partscount" value='"+partc+"' \>" +
an then do i use the name in the "to" on my cfloop?
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
No, don't set the name/ID to "partscount". Set it to partc as you had before (same for both ID and name. Note also that you now have two values (which is also incorrect). You need something like: - name='"+partc+"' id='"+partc+"'
No, don't set the name/ID to "partscount". Set it to partc as you had before (same for both ID and name. Note also that you now have two values (which is also incorrect). You need something like: - name='"+partc+"' id='"+partc+"'
Hey Acoder,
So like this - "<input type='hidden' name='"+partc+"' id='"+partc+"' value='"+partc+"' \>" +
an then for the to in the cfloop i call '"+partc+"' correct?
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
The value has to be a number, 0 initially. Look at what partc is set to (look earlier in the function, not sure which line). That's what Coldfusion will see. To see what this turns out in the browser, check the generated source in the browser and you will see that the name and ID are set to "partscount1" or "partscount2", etc. depending on the serial number. This is what is required in the cfloop.
The value has to be a number, 0 initially. Look at what partc is set to (look earlier in the function, not sure which line). That's what Coldfusion will see. To see what this turns out in the browser, check the generated source in the browser and you will see that the name and ID are set to "partscount1" or "partscount2", etc. depending on the serial number. This is what is required in the cfloop.
Hey Acoder,
So your saying it needs 'partscount'+count (which is what partc is set to) in the "to" in the cfloop ?
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
Yes, with 'count' being the serial number.
Yes, with 'count' being the serial number.
Hey Acoder,
So something like this correct? - <cfloop from="1" to="'partscount'+serialcount">
-
<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">
-
<!--- <cfquery param value="#submission#" CFSQLType = "CF_SQL_VARCHAR">--->
-
</cfquery>
-
</cfloop>
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
Not quite. It'd have to be a Coldfusion form variable like the serial count for the first loop.
Not quite. It'd have to be a Coldfusion form variable like the serial count for the first loop.
Hey Acoder,
So what would i use because i don't have any hidden fields in the parts function.
an all i have in the serial function is - "<input type='hidden' name='"+partc+"' id='"+partc+"' value='0' \>" +
-
"<input type='hidden' name='serialcount' id='serialcount' value='" + count + "'>";
an then is what i have for the html - <input type="hidden" value="0" id="theValue" name="theValue"/>
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
You don't need any in the parts function because the one(s) in the serial function is/are the count(s) for parts. What I suggest you do is turn on debugging so you can see what's being passed to your Coldfusion script. You should see all the form element names and values.
You don't need any in the parts function because the one(s) in the serial function is/are the count(s) for parts. What I suggest you do is turn on debugging so you can see what's being passed to your Coldfusion script. You should see all the form element names and values.
Hey Acoder,
So are you saying i need to pass serialcount in my cfloop?
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
The serialcount would be required to construct the form element name:
form["partscount" & serialcount]
The serialcount would be required to construct the form element name:
form["partscount" & serialcount]
Hey Acoder,
When i tried this i got the error
Attribute TO in tag CFLOOP has an invalid value
Cannot convert form['partscount'&serialcount] to number. - <cfloop from="1" to="form['partscount'&serialcount]">
an when i tried this it was having issues with the " - <cfloop from="1" to="form["partscount"&serialcount]">
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
That's a Coldfusion variable, so it has to be within ##
That's a Coldfusion variable, so it has to be within ##
Hey Acoder,
Does the serialcount or the partscount need to be in ##? an does partscount still need '' around it? - <cfloop from="1" to="form['partscount' & #serialcount#]">
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
The whole thing: #form[...]#
The whole thing: #form[...]#
Hey Acoder,
its having issues with the cfloop. was not earlier for some reason but i am now. it says
Attribute set validation error in tag CFLOOP
The tag has an invalid attribute combination: the most likely attribute combination is
Required attributes: 'FROM,INDEX,TO'. Optional attributes: 'STEP'. - <cfloop from="1" to="#form['partscount' & serialcount]#">
-
<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">
-
<!--- <cfquery param value="#submission#" CFSQLType = "CF_SQL_VARCHAR">--->
-
</cfquery>
-
</cfloop>
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
You forgot the index attribute - see the first cfloop.
You forgot the index attribute - see the first cfloop.
Hey Acoder,
It works perfectly for inserting only one serial and one part. But when i tried more i got the following error
An error occurred while evaluating the expression:
"#form['partscount' & serialcount]#"
Error near line 95, column 27.
--------------------------------------------------------------------------------
The member "PARTSCOUNT1,2" in dimension 1 of object "form" cannot be found. Please, modify the member name.
an well line 95 is the cfloop. - <cfloop from="1" to="#form['partscount' & serialcount]#" index="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>
-
Thank you :),
Rach
acoder 16,027
Recognized Expert Moderator MVP
Right, I see. Instead of serialcount, you'll want to use machinecount (the index variable of the first loop).
Right, I see. Instead of serialcount, you'll want to use machinecount (the index variable of the first loop).
Hey Acoder,
So like this? does the index need to be removed or put a different name behind index? - <cfloop from="1" to="#form['partscount' & machinecount]#" index="machineCount">
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
Yes, you should use a different name to avoid problems.
Yes, you should use a different name to avoid problems.
Hey Acoder,
I did this - <!---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">
-
<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>
but i am getting the following error
An error occurred while evaluating the expression:
hcpn = Form["hcpn_" & machineCount]
Error near line 60, column 8.
--------------------------------------------------------------------------------
The member "HCPN_2" in dimension 1 of object "Form" cannot be found. Please, modify the member name.
an the error comes from in the cfset area - <!---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 hcpn = Form["hcpn_" & machineCount]>
-
<CFSET partsreturn = Form["partsreturn_" & machineCount]>
-
<CFSET defective = Form["defective_" & machineCount]>
-
<!--- <CFSET followdate = Form["followdate_" & machineCount]>
-
<CFSET onsite = Form["onsite_" & machineCount]>
-
<CFSET numonsite = Form["numonsite_" & machineCount]>--->
-
-
<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">
-
<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
acoder 16,027
Recognized Expert Moderator MVP
The variables corresponding to the parts query should be in the second cfloop. Check what you've named the parts fields.
The variables corresponding to the parts query should be in the second cfloop. Check what you've named the parts fields.
Hey Acoder,
i checked the fields an there named correctly unless instead of hcpn it needs to be hcpn_
here is what i got in the javascript for it - "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0' >" +
-
"<th class='sectiontitle' colspan='7'>Parts Information "+ count +" Serial Information "+serialno+"</th>" +
-
"<tr>" +
-
"<td class='indent' id='formfieldpadding'>HC P/N: <input type='text' name='hcpn_" + count + "' style='margin:0px'></td>" +
-
"<td class='red'>" +
-
"Parts been returned* " +
-
"<input type='checkbox' name='partsreturn_" + count +"' value='1'/>" +
-
"</td>" +
-
"<td>" +
-
"<td class='indent'>Defective<input type='checkbox' name='defective_" + count +"' value='1'/></td>" +
-
"</td>" +
-
"</tr>" +
-
"</table>" +
and here is what i have for the submitting - <cfloop from="1" to="#form['partscount' & machinecount]#" index="ps">
-
<CFSET hcpn = Form["hcpn_" & machineCount]>
-
<CFSET partsreturn = Form["partsreturn_" & machineCount]>
-
<CFSET defective = Form["defective_" & 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>
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
In that loop, for the parts query variables, you should replace machineCount with ps (the index variable).
In that loop, for the parts query variables, you should replace machineCount with ps (the index variable).
Hey Acoder,
It worked, but didn't work. It inserted into the table but not how it needs to insert.
When it inserted instead of creating a separate record for each part. It made 2 records but put the information from both parts in both records
example
here is how it looks
record 1: hc_part no: test 1 p, test 2 p
record 2: hc_part no: test 1 p, test 2 p
an how it needs to look
record 1: hc_part no: test 1 p
record 2: hc_part no: test 2 p
do i need to add this line to the top of parts? - <CFIF REQUEST_METHOD EQ "POST">
here is what i have for parts - <cfloop from="1" to="#form['partscount' & machinecount]#" index="ps">
-
<CFSET hcpn = Form["hcpn_" & ps]>
-
<CFSET partsreturn = Form["partsreturn_" & ps]>
-
<CFSET defective = Form["defective_" & ps]>
-
<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>
Thank you :),
Rach
acoder 16,027
Recognized Expert Moderator MVP
Does this affect just hcpn or all three variables?
Does this affect just hcpn or all three variables?
Hey Acoder,
It affects all 3 fields
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
Either check on the client-side (using, say, Firebug) what the generated source is when you have two parts, or turn debugging on and check what's passed through to Coldfusion. Check the names of the parts input fields.
You should turn debugging on anyway if you haven't already done so. On a development machine it should be turned on so you can get useful information about your application.
Hey Acoder,
With the debugging for coldfusion i don't have the ability to turn it on because its controlled by the main web developer. Basically the errors i get are what i get.
but i opened up firebug an i didn't see anything that stands out. Basically here is what i get when i have to parts though.this is looking at the html of it.
dynamic1input
part1name1
dynamic2input
part1name2
an i noticed in the database that it puts the hcpn field like this part 1,part 2
however for all the other fields it only puts one value in those.
But here is what i have in full - <!---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]>--->
-
-
<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">
-
<CFSET hcpn = Form["hcpn_" & ps]>
-
<CFSET partsreturn = Form["partsreturn_" & ps]>
-
<CFSET defective = Form["defective_" & ps]>
-
<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
acoder 16,027
Recognized Expert Moderator MVP
Check the three variables in Firebug by expanding one part (the +) and see the values.
Is there no chance you could ask the main web developer to switch it on for you. Surely it'd make things easier.
Check the three variables in Firebug by expanding one part (the +) and see the values.
Is there no chance you could ask the main web developer to switch it on for you. Surely it'd make things easier.
Hey Acoder,
Well with the main developer, i can never get a hold of him. We was suppose to go over something a week an a half ago an still haven't. But i did notice something looking for the 3 variables.
dynamic1input has this - <input id="partscount1" type="hidden" value="1" name="partscount1"/>
-
<input id="serialcount" type="hidden" value="1" name="serialcount"/>
dynamic2input - <input id="partscount2" type="hidden" value="1" name="partscount2"/>
-
<input id="serialcount" type="hidden" value="2" name="serialcount"/>
an when i looked under part1Name1 and part1Name2 all the fields had hcpn_1 partsreturn_1 and defective_1. I don't know if that means anything but thought i would point it out.
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
That will be the problem. All parts variables have the same name, so when passed to Coldfusion, it's passed as a list which is what's being added to the database.
What you'll need to do is make all parts fields unique. You can do that by adding the serial count to the name, e.g. by adding "_" + serialcount, then modifying the Coldfusion to get each unique parts field.
That will be the problem. All parts variables have the same name, so when passed to Coldfusion, it's passed as a list which is what's being added to the database.
What you'll need to do is make all parts fields unique. You can do that by adding the serial count to the name, e.g. by adding "_" + serialcount, then modifying the Coldfusion to get each unique parts field.
Hey Acoder,
I get what your saying, just not sure on the naming part. So would something like this work? - <input type='text' name='hcpn_" + count + "_"+serialcount"' style='margin:0px'>
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
Almost - you forgot the + after serialcount.
Almost - you forgot the + after serialcount.
Hey Acoder,
Does it need to be serialcount or serialno? because it says serialcount is undefined. here is what i have - "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0' >" +
-
"<th class='sectiontitle' colspan='7'>Parts Information "+ count +" Serial Information "+serialno+"</th>" +
-
"<tr>" +
-
"<td class='indent' id='formfieldpadding'>HC P/N: " +
-
"<input type='text' name='hcpn_" + count + "_"+serialcount+"' style='margin:0px'></td>" +
-
"<td class='red'>" +
-
"Parts been returned* " +
-
"<input type='checkbox' name='partsreturn_" + count +"_"+serialcount+"' value='1'>" +
-
"</td>" +
-
"<td>" +
-
"<td class='indent'>Defective<input type='checkbox' name='defective_" + count +"_"+serialcount+"' value='1'>" +
-
"</td>" +
-
"</td>" +
-
"</tr>" +
-
"</table>";
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
Yes, then it must be serialno, not serialcount.
Yes, then it must be serialno, not serialcount.
Hey Acoder,
Ok then in my cfloop would it be like this? or do i need to get serialno in here as well? - <cfloop from="1" to="#form['partscount' & machinecount]#" index="ps">
-
<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>
Thank you,
Rach
acoder 16,027
Recognized Expert Moderator MVP
If you're going to put machinecount in the string, then wrap it in #s or take it out of the string like ps.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: jason |
last post by:
How does one loop through the contents of a form complicated by dynamic
construction of checkboxes which are assigned a 'model' and 'listingID' to
the NAME field on the fly in this syntax:...
|
by: Joe |
last post by:
Hey,
I'm going to give some background on my situation in case anyone can
point out a way around my problem altogether... for the problem
itself, please skip to the bottom of the post. thanks....
|
by: Maria L |
last post by:
I have a client who needs to copy an existing sale. The problem is
the Sale is made up of three tables: Sale, SaleEquipment, SaleParts.
Each sale can have multiple pieces of equipment with...
|
by: Graham |
last post by:
I have been having some fun learning and using the new Controls and methods in .Net 2.0 which will make my life in the future easier and faster. Specifically the new databinding practises and...
|
by: icfai |
last post by:
hi friends....
I have got a problem regarding loading of multiple assemblies, actually its required for an editor which implements the intellisenseas in vb or dotnet.
for that it is required to...
| |
by: Otis492 |
last post by:
Hello,
I have been struggling with this for a while. I am working on a rather simple database for claims in Access 2003. I have a table called claims that has a primary key field called Claim #. ...
|
by: bonneylake |
last post by:
Hey Everyone,
Well i was hoping someone could explain the best way i could go about this.
i have a few ideas on how i could go about this but i am just not sure if it would work.
Right now i...
|
by: bonneylake |
last post by:
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.
...
|
by: planethax |
last post by:
I have multiple arrays that I need to insert/update database and I am not sure how to start, I think I need to use the "foreach" statement and also not sure whether or not to serialize and...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |