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 Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder 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)? Hey Acoder,
It still occurs when i don't add a part. An it happens when i add a part an then delete it.
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
<cfloop> has a number of different types. The one you're using here is an index loop. You can also use a conditional loop which might make sense here. You check the condition before entering the loop. See documentation.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder <cfloop> has a number of different types. The one you're using here is an index loop. You can also use a conditional loop which might make sense here. You check the condition before entering the loop. See documentation. Hey Acoder,
well the only thing i am worried about the conditional loop is i don't know how many parts they will add or if they will add a part. So would it still work if i had a part or if i didn't have a part? an then if it would work would what i set cfset to. In the example they use <cfset CountVar = 0> do i need to set mine to something like - <cfset ps = "#form['partscount' & machinecount]#">
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
You could set ps to 1 then in the cfloop condition, check that it's less than the count. If the count is 0, the code in the loop wouldn't execute.
There's one other approach which may make sense here. It ties in with the second method for deleting parts where you have a list of part numbers. Here you would loop over the list. If the list is empty, it doesn't try to insert parts.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder You could set ps to 1 then in the cfloop condition, check that it's less than the count. If the count is 0, the code in the loop wouldn't execute.
There's one other approach which may make sense here. It ties in with the second method for deleting parts where you have a list of part numbers. Here you would loop over the list. If the list is empty, it doesn't try to insert parts. Hey Acoder,
Well whatever direction you think would be best then all go with that.So if i was to go with the second idea you have how would i go about that.
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Keep a hidden field to list the part numbers separated by commas, i.e. a Coldfusion list, e.g. "1,3,4,5,". This could either be in addition to the count or replace it. In the add parts function, you would add the part number to the field with a comma. In the delete parts function, remove the number from the field. On the Coldfusion side, loop over this list.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Keep a hidden field to list the part numbers separated by commas, i.e. a Coldfusion list, e.g. "1,3,4,5,". This could either be in addition to the count or replace it. In the add parts function, you would add the part number to the field with a comma. In the delete parts function, remove the number from the field. On the Coldfusion side, loop over this list.
Hey Acoder,
ok i am mostly confused by the first part. Am i suppose to be creating a hidden field or a coldfusion list like below - <cfset coldfusion_list = "ColdFusion Lists,ColdFusion Arrays,ColdFusion Structures">
-
-
<cfloop list="#coldfusion_list#" index="i">
-
<cfoutput> #i# <br />
-
</cfloop>
an then where would this hidden field or coldfusion list go? would it go under the serial or parts function?
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
By hidden field, I meant an input field on the client side, e.g. - <input type="hidden" name="parts1list1" id="parts1list1" value="">
This would be set using JavaScript to "1," initially when the first part is added. As more are added/deleted, this list can become something like "1,2,4,5,"
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder By hidden field, I meant an input field on the client side, e.g. - <input type="hidden" name="parts1list1" id="parts1list1" value="">
This would be set using JavaScript to "1," initially when the first part is added. As more are added/deleted, this list can become something like "1,2,4,5," Hey Acoder,
So does it go to the place below or do i need to add it somewhere in the parts function? - <!--- Ticket Information --->
-
<input type="hidden" value="0" id="theValue" name="theValue"/>
-
<input type="hidden" name="parts1list1" id="parts1list1" value="">
-
<!---<input type="hidden" value="0" id="aValue" />
-
---> <div id="dynamicInput">
-
<!--- All Ticket Information and Parts information Appears Here--->
-
</div>
-
<input type="button" class="addticket" value="Add Serial" onClick="addInput('dynamicInput');" >
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
It should go next to the partscount input field in the addInput() function.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder It should go next to the partscount input field in the addInput() function. Hey Acoder,
So something like this correct? - "<input type='hidden' name='"+partc+"' id='"+partc+"' value='0'>" +
-
"<input type="hidden" name="parts1list1" id="parts1list1" value="">" +
-
"<input type='hidden' name='serialcount' id='serialcount' value='" + count + "'>";
-
-
<!--- Adds Delete to every ticket --->
-
newdiv.innerHTML = newdiv.innerHTML +
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Of course, "parts1list1" was only an example. It needs to be a variable constructed similar to partc.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Of course, "parts1list1" was only an example. It needs to be a variable constructed similar to partc. Hey Acoder,
Ok so i added this in the function addinput - var partc = 'partscount'+count;
-
var part2c = 'part2count'+count;
an then here is the 2 hidden fields - "<input type='hidden' name='"+partc+"' id='"+partc+"' value='0'>" +
-
"<input type="hidden" name='"+part2c+"' id='"+part2c+"' value="">" +
Is this correct?
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
That's one thing done. Then in addInput, you need to update this field with the count number plus a comma. In the delete function, remove the part number being deleted.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder That's one thing done. Then in addInput, you need to update this field with the count number plus a comma. In the delete function, remove the part number being deleted. Hey Acoder,
How would i go about updateing it? something like - part update = 'part2count'+count';
an then for delete, would i delete it like so from the addinput function? - <!---Allows us to remove multiple fields --->
-
function removeElement(divNum) {
-
var d = document.getElementById('dynamicInput');
-
var olddiv = document.getElementById(divNum);
-
d.removeChild.part2c(olddiv);
-
}
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Although this is now JavaScript, since it links with the Coldfusion, we can leave it in this thread.
For the adding, look how you update the parts count. Do something similar with this new field with the difference being that instead of setting the count value, you append it using +=
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Although this is now JavaScript, since it links with the Coldfusion, we can leave it in this thread.
For the adding, look how you update the parts count. Do something similar with this new field with the difference being that instead of setting the count value, you append it using += Hey Acoder,
Confused by, are you meaning something like - var partupdate = 'part2count'+=count';
or maybe - var partupdate = 'part2count'+count+=';
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Sorry, I meant in addpartInput(), you have something like: - var serialno = partName.replace("dynamic","").replace("Input","");
-
var avalue = document.getElementById("partscount"+serialno);
-
var count = parseInt(avalue.value) + 1;
-
avalue.value = count;
so you'd use something similar for parts2count except that instead of avalue.value = count, you'd set partslist.value += count + ",".
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Sorry, I meant in addpartInput(), you have something like: - var serialno = partName.replace("dynamic","").replace("Input","");
-
var avalue = document.getElementById("partscount"+serialno);
-
var count = parseInt(avalue.value) + 1;
-
avalue.value = count;
so you'd use something similar for parts2count except that instead of avalue.value = count, you'd set partslist.value += count + ",". Hey Acoder,
I added this to addpartInput. does it need to be partslist or does it need to part2c? - var count = parseInt(avalue.value) + 1;
-
avalue.value = count;
-
partslist.value += count + ",";
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
partslist was just a variable name that I made up. You'll need to set it to the element in question first before setting its value: - var partslist = document.getElementById("parts2count"+serialno);
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder partslist was just a variable name that I made up. You'll need to set it to the element in question first before setting its value: - var partslist = document.getElementById("parts2count"+serialno);
Hey Acoder,
So something like this correct? - avalue.value = count;
-
var partslist = document.getElementById("parts2count"+serialno);
-
partslist.value += count + ",";
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
That's one part done. Now you need to add some lines in the delete function to remove the part number being deleted. You'll need the serial number again, so you can copy that line. The input field value is a string, so you can use replace() like how you set the serialno variable.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder That's one part done. Now you need to add some lines in the delete function to remove the part number being deleted. You'll need the serial number again, so you can copy that line. The input field value is a string, so you can use replace() like how you set the serialno variable. Hey Acoder,
Not sure if i copied the 2 correct lines, but here is what i have. I added it to the delete function in the parts function - <!---Allows us to remove multiple fields--->
-
function removetheElement(divNum) {
-
var d = document.getElementById('partsInput');
-
var partslist = document.getElementById("parts2count"+serialno);
-
var serialno = partName.replace("dynamic","").replace("Input","");
-
var olddiv = document.getElementById(divNum);
-
olddiv.parentNode.removeChild(olddiv);
-
}
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
divNum which is passed into this function is partIdName set in the addpartInput function. partIdName is set like this: - var partIdName = 'part' + count + 'Name' + serialno;
so you need to do some string manipulation (see methods) to get the count and serial number values.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder divNum which is passed into this function is partIdName set in the addpartInput function. partIdName is set like this: - var partIdName = 'part' + count + 'Name' + serialno;
so you need to do some string manipulation (see methods) to get the count and serial number values. Hey Acoder,
Ok are you saying the 2 strings i added where incorrect an i need to add the line you have above? an then what type of string manipulation do i need to do to it? something like - var replace = partIDName.replace("part","count").replace("Name","serialno");
-
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
No. That line was where you set the div ID in addpartInput(). Notice the ID contains both the part number (count) that needs to be removed and the serial no. So it could be something like "part2Name2". To get the part number, you need to remove "part" from it and then you can split on "Name" to get an array [2,2].
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder No. That line was where you set the div ID in addpartInput(). Notice the ID contains both the part number (count) that needs to be removed and the serial no. So it could be something like "part2Name2". To get the part number, you need to remove "part" from it and then you can split on "Name" to get an array [2,2]. Hey Acoder,
Do i need to keep the 2 lines i added above in the remove? an i am confused on the split completely, here is what i tried but i got a feeling this is not right - var replace = partIDName.split("Name","serialno");
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
You'd need the partslist line, but not the serialno line which will be set from the divNum. Forget partIDName. That's what the variable was called when set in addpartinput. In the delete function, it's called divNum.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder You'd need the partslist line, but not the serialno line which will be set from the divNum. Forget partIDName. That's what the variable was called when set in addpartinput. In the delete function, it's called divNum. Hey Acoder,
Ok so something like this? - <!---Allows us to remove multiple fields--->
-
function removetheElement(divNum) {
-
var d = document.getElementById('partsInput');
-
var partslist = document.getElementById("parts2count"+serialno);
-
var replace = divnum.split("Name","serialno");
-
var olddiv = document.getElementById(divNum);
-
olddiv.parentNode.removeChild(olddiv);
-
}
an i got another question i wanted to ask you about. Right now i am working on the edit part of the form. An well i can not update previously submitted serial's an wanted to ask can cfqueryparam prevent you from updating your table? i copied the one i used to insert and just changed the exec from insert to update. But cant seem to get it. Keeps giving me the error Procedure or function usp_CS_UpdateInsertserial has too many arguments specified an i been trying to figure this out for days. Could you give me an idea of what it could be? i been looking online an said its to many parameters but i have checked it a million times an its right. The only thing i can think of is my update insert stored procedure is messed up.
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Try running that code and see what happens. It won't work. serialno won't be defined. You need to define it first before you can use it. Also, see the link I gave earlier to see how to use split(). You also need to remove "part" first by using replace().
As for the new question, start a new thread. There's enough sub-questions in this thread without adding yet another one ;)
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Try running that code and see what happens. It won't work. serialno won't be defined. You need to define it first before you can use it. Also, see the link I gave earlier to see how to use split(). You also need to remove "part" first by using replace(). Actually scrap that. I ain't got my thinking cap on!
Just pass the serial number and count in removetheElement() to make things a lot easier: - onclick=\"removetheElement('"+partIdName+"',"+serialno+","+count+")\"
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Actually scrap that. I ain't got my thinking cap on!
Just pass the serial number and count in removetheElement() to make things a lot easier: - onclick=\"removetheElement('"+partIdName+"',"+serialno+","+count+")\"
Hey Acoder,
Here is the remove for the parts section. Is there anything else it needs? -
"<input type='button' class='removeticket' value='Remove Parts ""+count +""' onclick=\"removetheElement('"+partIdName+"',"+serialno+","+count+")\"></a>" +
an also do i need to remove those 2 lines from the removetheelement function -
var partslist = document.getElementById("parts2count"+serialno);
-
var replace = divnum.split("Name","serialno");
an do i need to post my question in coldfusion or sql server? an i think i might have my own question for this sql problem figured out. It thinks that my pk_ticketID (which holds the ticket number) is the
serial number. If i take out pk_ticketID it says that pka_serialNo can not be null and the insert fails. In the cfset could i add or do i need to add pk_ticketID?
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
You'll need to add two parameters to the removetheElement function: - function removetheElement(divNum, serialno, partnum) {
Of those two lines, you don't need the replace line. You need to set partslist.value to itself, but replaced with partnum+',' missing.
Re. your SQL question. If you think it's a pure SQL question, post it in SQL Server, and if not, Coldfusion it is.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder You'll need to add two parameters to the removetheElement function: - function removetheElement(divNum, serialno, partnum) {
Of those two lines, you don't need the replace line. You need to set partslist.value to itself, but replaced with partnum+',' missing.
Re. your SQL question. If you think it's a pure SQL question, post it in SQL Server, and if not, Coldfusion it is. Hey Acoder,
Would this be correct? - <!---Allows us to remove multiple fields--->
-
function removetheElement(divNum, serialno, partnum) {
-
var d = document.getElementById('partsInput');
-
var partslist = document.getElementById("parts2count"+serialno);
-
partslist.value += partnum + ',';
-
var olddiv = document.getElementById(divNum);
-
olddiv.parentNode.removeChild(olddiv);
-
}
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Line 5 is not quite correct. You want to remove partnum from partslist, so use replace() to replace with "" to remove it.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields
[quote=acoder]Line 5 is not quite correct. You want to remove partnum from partslist, so use replace() to replace with "" to remove it.[/QUOTE
Hey Acoder,
are you meaning something like this? - partslist.value += replace(partnum) + ',';
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
No, replace is a String method, so it'd be applied to partslist.value. See how you've used it before. Something like: partslist.value.replace(partnum+',',"")
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder No, replace is a String method, so it'd be applied to partslist.value. See how you've used it before. Something like: partslist.value.replace(partnum+',',"") Hey Acoder,
so would this be right? - <!---Allows us to remove multiple fields--->
-
function removetheElement(divNum, serialno, partnum) {
-
var d = document.getElementById('partsInput');
-
var partslist = document.getElementById("parts2count"+serialno);
-
partslist.value.replace(partnum+',',"");
-
var olddiv = document.getElementById(divNum);
-
olddiv.parentNode.removeChild(olddiv);
-
}
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
What line 5 would do is remove the part number (which is what you want), but then it'd be lost because it's not set to anything. So you need to set the result of that to partslist.value.
PS. not sure what line 3 is doing there. It must have been left over from some old code.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder What line 5 would do is remove the part number (which is what you want), but then it'd be lost because it's not set to anything. So you need to set the result of that to partslist.value.
PS. not sure what line 3 is doing there. It must have been left over from some old code. Hey Acoder,
Well line 3 has always been there but do i need to remove it? an i am confused by what you mean about seeing the results of that to partlist.value. are you saying need to add it to the last line of code where it says olddiv.parentNode.removeChild(olddiv);?
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
You can safely remove it because it's never used.
To set partslist.value: - partslist.value = partslist.value.replace...
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder You can safely remove it because it's never used.
To set partslist.value: - partslist.value = partslist.value.replace...
Hey Acoder,
Is this correct? does it need anything else? -
<!---Allows us to remove multiple fields--->
-
function removetheElement(divNum, serialno, partnum) {
-
var partslist = document.getElementById("parts2count"+serialno);
-
partslist.value = partslist.value.replace(partnum+',',"");
-
var olddiv = document.getElementById(divNum);
-
olddiv.parentNode.removeChild(olddiv);
-
}
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
I don't think so. Test it now to see if it's all working on the client side.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder I don't think so. Test it now to see if it's all working on the client side. Hey Acoder,
Well it still don't work. Right now it wont display parts it says partslist has no properties and its refering to - var count = parseInt(avalue.value) + 1;
-
avalue.value = count;
-
var partslist = document.getElementById("parts2count"+serialno);
here is what i have in full the funcion for the serial - <script type="text/javascript">
-
<!---Allows us to add multiple fields --->
-
function addInput(divName){
-
var dynamic = document.getElementById('dynamicInput');
-
var thevalue = document.getElementById('theValue');
-
var count = (document.getElementById('theValue').value -1)+ 2;
-
thevalue.value = count;
-
var newdiv = document.createElement('div');
-
var getparts = document.createElement('div');
-
var divIdName = 'dynamic'+count+'Input';
-
var partc = 'partscount'+count;
-
var part2c = 'part2count'+count;
-
-
"<input type='hidden' name='"+partc+"' id='"+partc+"' value='0'>" +
-
"<input type='hidden' name='"+part2c+"' id='"+part2c+"' value=''>" +
-
"<input type='hidden' name='serialcount' id='serialcount' value='" + count + "'>";
for the parts function - <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 partslist = document.getElementById("parts2count"+serialno);
-
partslist.value += count + ",";
-
var partdiv = document.createElement('div');
-
var partIdName = 'part' + count + 'Name' + serialno;
and remove for parts section - <!---Allows us to remove multiple fields--->
-
function removetheElement(divNum, serialno, partnum) {
-
var partslist = document.getElementById("parts2count"+serialno);
-
partslist.value = partslist.value.replace(partnum+',',"");
-
var olddiv = document.getElementById(divNum);
-
olddiv.parentNode.removeChild(olddiv);
-
}
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
You've named/ID'ed it as "part2count...", not "parts2count...". Be consistent either way.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder You've named/ID'ed it as "part2count...", not "parts2count...". Be consistent either way. Hey Acoder,
Alrighty i fixed it, It lets me add and remove parts again. But it still when i submit it with no parts showing (meaning only selected the serial an no parts added to it) i get the error
An error occurred while evaluating the expression:
hcpn = Form["hcpn_" & ps & "_#machinecount#"]
Error near line 95, column 8.
The member "HCPN_1_1" in dimension 1 of object "Form" cannot be found. Please, modify the member name.
it basically says its having trouble with cfset hcpn on my userform.cfm. which here is the userform. - <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#"]>
-
<CFSET rma = Form["rma_" & 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">,
-
<cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">
-
</cfquery>
-
</cfloop>
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
You need to change the cfloop to loop over the part2count+machinecount list instead of 1 to a specific number.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder You need to change the cfloop to loop over the part2count+machinecount list instead of 1 to a specific number. Hey Acoder,
am i suppose to do it this way? - <cfloop from="1" to="#form['part2count' & 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#"]>
-
<CFSET rma = Form["rma_" & 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">,
-
<cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">
-
</cfquery>
-
</cfloop>
or this way - <cfloop from=#form.part2count#" 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#"]>
-
<CFSET rma = Form["rma_" & 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">,
-
<cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">
-
</cfquery>
-
</cfloop>
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: displaying previously entered multiple fields
Neither ;) You need to use the list attribute because you're looping over a list.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: displaying previously entered multiple fields Quote:
Originally Posted by acoder Neither ;) You need to use the list attribute because you're looping over a list. Hey Acoder,
Would something like this work? -
<cfloop list="#form['part2count' & machinecount]#" default="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#"]>
-
<CFSET rma = Form["rma_" & "#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">,
-
<cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">
-
</cfquery>
-
</cfloop>
Thank you,
Rach
|  | | | | | /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,272 network members.
|