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

Updating dynamic counter variable

LEGEND ,
Jan 08, 2008 Jan 08, 2008

Copy link to clipboard

Copied

I have a form that populates form fields with database records to edit.
This works fine.
When i attempt to loop through the records to update i get an error.
Obviously it has to do with my syntax of my variables (
LowerQty='form.LowerQty#count#', UpperQty='form.UpperQty#count#',
Price=form.Price#count# WHERE id='form.id#count'# )

When i attempt to update the database. It is attempting to enter the string
value "lowerQty1" rather that it actual intger value=1. What is the correct
syntax to write these variables in cold fusion? Thanks in advance.

<!----form------>
<cfset count=0>
<form name="form2" action="pricecode_adjust.cfm?stage=update"
method="post">
<table width="600" border="1">
<cfoutput query="PriceCodes" startrow="1"
maxrows="#pricecodes.recordcount#">
<cfset count=#count#+1>
<tr>
<td width="100px">Price Code:
#pricecode# <input name="id#count#" type="text"
value="#pricecodes.id[count]#" /></td>
<td width="100px">Lower Qty#count#:
<input type="text" name="LowerQty#count#" size="6" maxlength="6"
value="#pricecodes.lowerqty[count]#" /> </td>
<td width="100px">Upper Qty#count#:
<input type="text" name="UpperQty#count#" size="6" maxlength="6"
value="#pricecodes.upperqty[count]#" /></td>
<td width="100px">Price#count#: <input
type="text" name="Price#count#" size="6" maxlength="6"
value="#pricecodes.price[count]#" /></td>
</tr>
</table><input name="Update" type="submit" id="Update"
value="Update Price Code" />

<!-----store the loop count in hiiden field---->
<input name="recordcount" type="hidden" value="#pricecodes.recordcount#" />
</cfoutput>
</form>


<!----update------>
<cfif stage eq 'update'>
<!---Loop through pricecodes to be updated--------->
<cfloop index="Count" from="1" to="#form.recordcount#">

<cfquery name="query" datasource="#client.dsn#"
username="#client.username#" password="#client.password#">
UPDATE cost
SET
LowerQty='form.LowerQty#count#',
UpperQty='form.UpperQty#count#',
Price=form.Price#count#
WHERE
id='form.id#count'#
</cfquery>

</cfloop>
</cfif>


TOPICS
Advanced techniques

Views

339

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
LEGEND ,
Jan 08, 2008 Jan 08, 2008

Copy link to clipboard

Copied

LATEST
if you have tried looking for an answer first, you would have found it
in this very forum only 2 threads before yours!

http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=7&threadid=1328096&ente...

and another one only 4 before yours!!!

http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=7&threadid=1328004&ente...

and there was another one earlier today on exactly the same subject!

and don't forget to RTFM:
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Part_3_CFML_Ref_1.html

hth

---
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.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
Resources
Documentation