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

Cfoutput query and form field names

Explorer ,
Nov 11, 2012 Nov 11, 2012

Copy link to clipboard

Copied

I have a form that have two field inputs. I would like to repeat the form fields as part of a cfoutput query. The first field of the form automatically populates the different person's name (via cfoutput query) and this form field is called "tenant". The next field of the form is called "sales". The sales field is left open for user imput. The entire form is in between the cfoutput query tags. When the cfoutput query is executed, Both form fields of the form is displayed with each tenant name listed in each of the first form fields of each row. The problem I'm running into is that even though the form elements appear to display correctly, I would like the name of each of my form elements in the cfoutput query, of each row to have a different form field name like, tenant2, sales2, tenant3, sales3 etc. is that possible?

Here's what my code look like.

<cfform action= "addsales.cfm" method="post">

<cfoutput query="tenantsales"><Input name="tenant" type="text" value="#office.tenant#" size="32" />

<select name="sales"><option>$5</option><option>$10</option><option>$12</option></br></cfoutput>

<input name="submit" type="submit" />

</cfform>

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
LEGEND ,
Nov 11, 2012 Nov 11, 2012

Copy link to clipboard

Copied

If your query includes a tenantId, use that.  <input name="tenant#tenantId#" etc.

If not, use the currentrow variable from the cfoutput tag.

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 ,
Nov 12, 2012 Nov 12, 2012

Copy link to clipboard

Copied

Thank you for the information that is exactly what i was looking for. I ended up using the tenant#tenantId#  and it work like a charm. Now i would like to be able to pass the form field variable the same way. However I'm having some difficulties when i do the following:

<cfquery name="AddSales" datasource="master">

INSERT INTO sales (salid,

saltenant,

salsales)

VALUES ('00',

'#form.tenant#',

'#form.sales#');

The form field values are not passing to my action page.

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
LEGEND ,
Nov 12, 2012 Nov 12, 2012

Copy link to clipboard

Copied

LATEST

You'll have to use array notation:

form["static part" & variable part]

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
Community Expert ,
Nov 11, 2012 Nov 11, 2012

Copy link to clipboard

Copied

I cannot imagine why you would want to show a list of pre-populated input fields. What makes sense to me is a select-box. If that is indeed what you want, then you could do something like this:

<cfform action= "addsales.cfm" method="post">

<cfselect name="tenant">

    <option value="">Tenant</option>

<cfoutput query="tenantsales">

    <option value="#tenantsales.tenantID#">#tenantsales.tenantName#</option>

</cfoutput>

</cfselect></br>

<cfselect name="sales">

<option value="">Sales</option>

<option value="5">$5</option>

<option value="10">$10</option>

<option value="12">$12</option>

</cfselect></br>

<cfinput name="submit" type="submit" value="Submit" />

</cfform>

Like Dan, I have assumed your database table has a column for tenant 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
Resources
Documentation