• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Looping through form

Explorer ,
Sep 19, 2007 Sep 19, 2007

Copy link to clipboard

Copied

I have a page, http://www.boey.com/hms/vbc/vbc_edit_po.cfm?PO=333 that I need to save the data per "line_id" on the next page. However, when I loop through the "Line_id" it puts the data from the form fields, "W/S" like this... 45,50 so I tried looping through both "Line_id" and "w/s" and it doesn't work. How can I can update my table from this form? There are two different tries in my attached code.

Thanks,
Courtney
TOPICS
Advanced techniques

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2007 Sep 19, 2007

Copy link to clipboard

Copied

I had a very similar situation and this tutorial helped me. Try it.
http://tutorial214.easycfm.com/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 09, 2007 Oct 09, 2007

Copy link to clipboard

Copied

I've worked through the tutorial and I'm stuck with a problem still. Please take a look at the following code:

Website page can be located at http://www.boey.com/hms/vbc/vbc_edit_po.cfm?PO=333

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 09, 2007 Oct 09, 2007

Copy link to clipboard

Copied

First thing you'll notice that in the tutorial - there are 2 lines for each variable. That is just the way it work when using Evaluate. However, from reading these forums, I gather 'Evaluate' is not the best function to use. So here's a method to achive the same in a single line.

Your first variable would look like the attached code. Do this for all your variables and it should work.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 09, 2007 Oct 09, 2007

Copy link to clipboard

Copied

> <cfset variables.Line_ID = #Form["Line_ID" & LoopCount]#>

.. but lose the the # signs. They're not needed.

<cfset variables.Line_ID = Form["Line_ID" & LoopCount]>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

Neither of those suggestions are working. I tried various things with those two statements and I'm still getting an error which is below. What is weird is that it reads this from the previous page..

<input type="Text" name="LineID#GetInfo.CurrentRow#" value="#GetInfo.Line_id#">

Since the code you provided is still not working maybe I have this statement incorrect. Getting frustrated.

---------------------------------------------------------------------------------------------------------------------------

Error Occurred While Processing Request

Error Diagnostic Information

An error occurred while evaluating the expression:

variables.Line_ID = Form["Line_ID" & LoopCount]

Error near line 4, column 10.

The member "LINE_ID1" in dimension 1 of object "Form" cannot be found. Please, modify the member name.

The error occurred while processing an element with a general identifier of (CFSET), occupying document position (4:4) to (4:58).

Date/Time: 10/10/07 10:53:28
Browser: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7
Remote Address: 76.6.58.23
HTTP Referrer: http://www.boey.com/hms/vbc/vbc_edit_po.cfm?PO=333
Query String: ID=

Please inform the site administrator that this error has occurred (be sure to include the contents of this page in your message to the administrator).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

> <input type="Text" name="LineID#GetInfo.CurrentRow#" value="#GetInfo.Line_id#">

Your form field names don't match. The input field name starts with LineID but you're using Line_ID

Try instead
<cfset variables.Line_ID = Form["LineID" & LoopCount]>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

Now that seems to be working but I'm still getting an error...


Error Occurred While Processing Request

Error Diagnostic Information

ODBC Error Code = 07001 (Wrong number of parameters)

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 8.

Hint: The cause of this error is usually that your query contains a reference to a field which does not exist. You should verify that the fields included in your query exist and that you have specified their names correctly.

The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (10:4) to (10:51).

Date/Time: 10/10/07 11:22:17
Browser: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7
Remote Address: 76.6.58.23
HTTP Referrer: http://www.boey.com/hms/vbc/vbc_edit_po.cfm?PO=333
Query String: ID=

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

Is that error from the update query, because the UPDATE seems to use only 7 fields?

1. Are the table column names are correct
2. Check the data types of the columns against the cfsqltypes. Are they correct?
You're using cf_sql_varchar for the "del_ Date" column. Is del_Date really a 'text' column?

3. You're using null="yes" for all of the parameters. That seems wrong because it will update the columns with NULL and ignore the form values.



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

Does the query actually work without the cfqueryparam's?

This isn't tested, so there may be typos.

<cfquery name="UpdateInfo" datasource="fabrics">
UPDATE tbl_orders
SET W_S = '#variables.w_s#',
del_Date = '#variables.del_Date#',
pieces = '#variables.pieces#',
piece_length = '#variables.piece_length#',
other_pieces = '#variables.other_pieces#',
po_comments = '#variables.po_comments#'
WHERE Line_ID = #variables.Line_ID#
</cfquery>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

I got it to work just fine. I'm working out some other details that have to with other items on that form. May have more questions at some point.
Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

Glad you got it working.

Hopefully you figured out how to do it with <cfqueryparam>. It has some extra benefits when used inside a cfloop, due to the usage of bind variables.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

I did. I've attached the code in case someone else is looking to do the same thing.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

I assume you accidentally left out the WHERE clause in the second update. Otherwise, you'd be updating all records in tbl_comments every time.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

Yes. That piece is still being worked out. Should have left it out.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

LATEST
Okay. Good luck with the rest of your form 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation