loop over list question
Hey Everyone, well i been trying to figure this out for days but i am having no luck. In my form i am able to add multiple serial numbers an it all goes into the database with no problems. However, i need every serial number i add to create a new field an not go into the same field This is how it is going in there now serial number: 1234,223 next field: blah, blah2 an i need it to go into my database like serial number: 1234 next field: blah serial number: 223 next field: blah2 to accomplish this i been trying to loop over a list.Right now i am able to make the first field in my form (Form.serialnum) accomplish this. However, i can not get the rest of the fields to do this because of Form.ID. If i try to put the Form.ID in my list it says that i didn't declare it. however, if i leave it in my cfquery it works except it doesn't put any of the fields past ID into the database like i need it to. I admit i am not the best at coldfusion and i been trying, but i am just lost on where to go at this point. If you could tell me what i am doing wrong or have any suggestions i would very much appreciate it. The code i been trying it below Thank you to all who help. exec usp_CS_Insertserial '#x#','#Form.ID#','#Form.modelno#','#Form.producttype#','#Form.softhardware#', '#Form.resolution#','#Form.resdate#','#Form.resvertified#','#Form.vertifidate#', '#Form.deptvendor#','#Form.hardwarefailure#','#Form.rma#' ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309063 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: loop over list question
One way to troubleshoot this is to remove the and replace with See what you're generating and passing to the DB Copy the output and place it in your DB GUI and run it.. You'll find out pretty quick if it's CF or the DB.. So you have all your fields in one huge list? You could loop over the list and create a list for each column for your DB.. If you know how many columns you are passing to the DB (which apparently you do), you could get a count of the entire list divided by the columns of your DB. Why are you using a store proc for inserting into your DB? Just use . Let me know if I need to explain anything else further.. On Tue, Jul 15, 2008 at 9:09 AM, Rachel B <[EMAIL PROTECTED]> wrote: > Hey Everyone, > > well i been trying to figure this out for days but i am having no luck. In my > form i am able to add multiple serial numbers an it all goes into the > database with no problems. However, i need every serial number i add to > create a new field an not go into the same field > > This is how it is going in there now > serial number: 1234,223 next field: blah, blah2 > > an i need it to go into my database like > serial number: 1234 next field: blah > serial number: 223 next field: blah2 > > to accomplish this i been trying to loop over a list.Right now i am able to > make the first field in my form (Form.serialnum) accomplish this. However, i > can not get the rest of the fields to do this because of Form.ID. If i try to > put the Form.ID in my list it says that i didn't declare it. however, if i > leave it in my cfquery it works except it doesn't put any of the fields past > ID into the database like i need it to. I admit i am not the best at > coldfusion and i been trying, but i am just lost on where to go at this > point. If you could tell me what i am doing wrong or have any suggestions i > would very much appreciate it. The code i been trying it below > > Thank you to all who help. > > > > exec usp_CS_Insertserial > '#x#','#Form.ID#','#Form.modelno#','#Form.producttype#','#Form.softhardware#', > '#Form.resolution#','#Form.resdate#','#Form.resvertified#','#Form.vertifidate#', > '#Form.deptvendor#','#Form.hardwarefailure#','#Form.rma#' > > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309065 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: loop over list question
Thank you greg for replying. I am pretty sure that there is nothing wrong with the database because the information still gets submitted in there. The way i have the cfloop now all the information still gets submitted into the database. Except, the problem is, is how it submits. This is how it submits serial number: 1 ID:3 model no: test, test1 serial number: 2 ID:3 model no: test, test1 when it gets to the model no and rest of fields it needs to be like this serial number: 1 ID:3 model no: test serial number: 2 id:3 model no: test1 but for some reason if i try to put the Form.ID out of cfquery an into the list it just gives me the error converting data type varchar to datetime. i thought it was giving me the didn't declare error, my bad. But if i was going to do it your way, loop over the list an create a list for each column in db, how would i go about that? pretty new to coldfusion so not really sure how i would do that. again thank you for all the help i really appreciate it. >One way to troubleshoot this is to remove the and replace >with >See what you're generating and passing to the DB Copy the output >and place it in your DB GUI and run it.. >You'll find out pretty quick if it's CF or the DB.. > >So you have all your fields in one huge list? >You could loop over the list and create a list for each column for your DB.. >If you know how many columns you are passing to the DB (which >apparently you do), >you could get a count of the entire list divided by the columns of your DB. >Why are you using a store proc for inserting into your DB? >Just use . > >Let me know if I need to explain anything else further.. > > > > >> ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309095 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: loop over list question
Thank you greg for replying. I am pretty sure that there is nothing wrong with the database because the information still gets submitted in there. The way i have the cfloop now all the information still gets submitted into the database. Except, the problem is, is how it submits. This is how it submits serial number: 1 ID:3 model no: test, test1 serial number: 2 ID:3 model no: test, test1 when it gets to the model no and rest of fields it needs to be like this serial number: 1 ID:3 model no: test serial number: 2 id:3 model no: test1 but for some reason if i try to put the Form.ID out of cfquery an into the list it just gives me the error converting data type varchar to datetime. i thought it was giving me the didn't declare error, my bad. But if i was going to do it your way, loop over the list an create a list for each column in db, how would i go about that? pretty new to coldfusion so not really sure how i would do that. again thank you for all the help i really appreciate it. >One way to troubleshoot this is to remove the and replace >with >See what you're generating and passing to the DB Copy the output >and place it in your DB GUI and run it.. >You'll find out pretty quick if it's CF or the DB.. > >So you have all your fields in one huge list? >You could loop over the list and create a list for each column for your DB.. >If you know how many columns you are passing to the DB (which >apparently you do), >you could get a count of the entire list divided by the columns of your DB. >Why are you using a store proc for inserting into your DB? >Just use . > >Let me know if I need to explain anything else further.. > > > > >> ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309096 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: loop over list question
Rachel, Can you the form scope and paste the output into a message? It would help to see how the form data is constructed. Carl Rachel B wrote: > Hey Everyone, > > well i been trying to figure this out for days but i am having no luck. In my > form i am able to add multiple serial numbers an it all goes into the > database with no problems. However, i need every serial number i add to > create a new field an not go into the same field > > This is how it is going in there now > serial number: 1234,223 next field: blah, blah2 > > an i need it to go into my database like > serial number: 1234 next field: blah > serial number: 223 next field: blah2 > > to accomplish this i been trying to loop over a list.Right now i am able to > make the first field in my form (Form.serialnum) accomplish this. However, i > can not get the rest of the fields to do this because of Form.ID. If i try to > put the Form.ID in my list it says that i didn't declare it. however, if i > leave it in my cfquery it works except it doesn't put any of the fields past > ID into the database like i need it to. I admit i am not the best at > coldfusion and i been trying, but i am just lost on where to go at this > point. If you could tell me what i am doing wrong or have any suggestions i > would very much appreciate it. The code i been trying it below > > Thank you to all who help. > > > > exec usp_CS_Insertserial > '#x#','#Form.ID#','#Form.modelno#','#Form.producttype#','#Form.softhardware#', > '#Form.resolution#','#Form.resdate#','#Form.resvertified#','#Form.vertifidate#', > '#Form.deptvendor#','#Form.hardwarefailure#','#Form.rma#' > > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309098 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: loop over list question
Well i wanted to thank both of you for the help, an i was able to solve my problem. By putting a counter in it i am able to accomplish my goal. the only thing i got to figure out is why it doesn't put the correct information into my 2nd serial. Like it i fill out 2 serial numbers and press submit, it puts the first line of information correct, however, where ever i have counter in my code, instead of putting what i put for the 2nd serial it puts what i put for the first serial. heres an example serial number: 61 ticket no:606 product type: all serial number: 61 ticket no:606 prodcut type: all (although i put desktop in here it says all like in the first one). but here is a copy of my code in case anyone else runs into a similar problem as me. again thank you both for helping me. exec usp_CS_Insertserial '#x#','#Form.ID#','#Form.modelno#','#ListGetAt(Form.producttype,counter)#','#Form.softhardware#', '#Form.resolution#','#Form.resdate#','#Form.resvertified#','#Form.vertifidate#','#Form.deptvendor#','#Form.hardwarefailure#',' #Form.rma#' ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309135 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: loop over list question
Rachel, It would still be helpful if you could post a dump of the form scope so we can see the structure of the data being passed into your template. We would likely be able to provide you with more intelligent suggestions than from looking at your query alone. Thanks, Carl Rachel B wrote: > Well i wanted to thank both of you for the help, an i was able to solve my > problem. By putting a counter in it i am able to accomplish my goal. the only > thing i got to figure out is why it doesn't put the correct information into > my 2nd serial. Like it i fill out 2 serial numbers and press submit, it puts > the first line of information correct, however, where ever i have counter in > my code, instead of putting what i put for the 2nd serial it puts what i put > for the first serial. > > heres an example > > serial number: 61 ticket no:606 product type: all > serial number: 61 ticket no:606 prodcut type: all (although i put desktop in > here it says all like in the first one). > > but here is a copy of my code in case anyone else runs into a similar problem > as me. again thank you both for helping me. > > > > >exec usp_CS_Insertserial > > '#x#','#Form.ID#','#Form.modelno#','#ListGetAt(Form.producttype,counter)#','#Form.softhardware#', > > '#Form.resolution#','#Form.resdate#','#Form.resvertified#','#Form.vertifidate#','#Form.deptvendor#','#Form.hardwarefailure#',' >#Form.rma#' > > > > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309141 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: loop over list question
Here is the form i am working with. 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 divIdName = 'dynamic'+count+'Input'; newdiv.setAttribute('id',divIdName); newdiv.innerHTML = "" + "
Serial Information "+ count +" " + "" + " " + "Model No: " + "" + "" + "" + " " + "" + " Product Type:" + " " + "" + "" + " " + "" + " Type Of Hardware Failure*:" + " " + "" + "" + " " + ""; newdiv.innerHTML = newdiv.innerHTML + "
" + "
"; newdiv.innerHTML = newdiv.innerHTML + "" + " " + "" + "Serial Number: " + "" + " Software/Hardware: " + "" + " " + "" + "
"; newdiv.innerHTML = newdiv.innerHTML + "" + " " + "" + "Description: " + " " + "" + "( You may enter up to 500 characters. )"+ " " + "
" + "" + "" + "
"; newdiv.innerHTML = newdiv.innerHTML + "" + " " + "" + "Resolution: " + " " + "" + "( You may enter up to 500 characters. )"+ " " + "
" + "" + "" + "
"; newdiv.innerHTML = newdiv.innerHTML + "" + " " + "" + "Resolution Date: (MM/DD/) " + " " + "" + " " + " Current Date: " + "" + " " + "" + "Resolution Verified as effective by: " + " " + "" + "" + " " + "" + "
"; newdiv.innerHTML = newdiv.innerHTML + "" + " " + "" + "Verification Date: (MM/DD/) " + " " + "" + " " + " Current Date: " + "" + " " + "" + "
" + " " + "Dept/Vendor Responsibility*: " + "