Should it be...
<cfloop index="i" from="1" to="#FORM.discount_category_count#" step="1">
<cfscript>
tmp = structnew();
tmp.ind_inpatient = 0;
tmp.ind_outpatient = 0;
if (isDefined(FORM["ind_inpatient_" & i]) AND
FORM["ind_inpatient_" & i] EQ 1) {
tmp.ind_inpatient = 1;
}
if (isDefined(FORM["ind_outpatient_" & i]) AND
FORM["ind_outpatient_" & i] EQ 1) {
tmp.ind_outpatient = 1;
}
tmp.discount_amt = FORM["discount_value_" & i];
tmp.ind_invoice = FORM["ind_invoice_" & i];
</cfscript>
</cfloop>
?
-----Original Message-----
From: Pete Ruckelshaus [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 20, 2007 2:41 PM
To: CF-Talk
Subject: Need help - looping through dynamic variables
I have a form with a set of checkboxes. There could be any number of
rows of checkboxes, since the fields are populated from the database
(values come from a lookup table). I am passing the number of rows to
expect when the form is processed via the "discount_category_count"
form field. The set of field names are "ind_inpatient_1",
"ind_inpatient_2", etc.
The code:
<cfloop index="i" from="1" to="#FORM.discount_category_count#" step="1">
<cfscript>
tmp = structnew();
tmp.ind_inpatient = 0;
tmp.ind_outpatient = 0;
if (isDefined(FORM["ind_inpatient_"][i]) AND
FORM["ind_inpatient_"][i] EQ 1) {
tmp.ind_inpatient = 1;
}
if (isDefined(FORM["ind_outpatient_"][i]) AND
FORM["ind_outpatient_"][i] EQ 1) {
tmp.ind_outpatient = 1;
}
tmp.discount_amt = FORM["discount_value_"][i];
tmp.ind_invoice = FORM["ind_invoice_"][i];
</cfscript>
</cfloop>
The problem is, this is throwing the following error:
Element ind_inpatient_ is undefined in a Java object of type class
coldfusion.filter.FormScope referenced as
and the line number for the error is the first IF statement in the
cfscript block.
What am I doing wrong?
Thanks.
Pete
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 by AdobeĀ®
Dyncamically transform webcontent into Adobe PDF with new ColdFusion MX7.
Free Trial. http://www.adobe.com/products/coldfusion
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:270219
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4