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

index loop with form variables

Guest
Apr 01, 2008 Apr 01, 2008

Copy link to clipboard

Copied

I hope this has a really easy answer...

I would like to run this through an index loop 1 to 58, but I can't make the checked understand the nested index variable.

How can I write
<cfloop index="i" from="1" to="58">
<cfif #form.#i## EQ "on"> do this, do that </cfif>
</cfloop>

Any ideas are more than welcome.
TOPICS
Advanced techniques

Views

309

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 ,
Apr 01, 2008 Apr 01, 2008

Copy link to clipboard

Copied

dazormiq wrote:
> Any ideas are more than welcome.

Array Notation, learn it, love it. It will make you appear all powerful
among your peers.

<cfif form EQ 'on'>...</cfif>

P.S. Your form fields are really just named '1', '2', ... '58'? Not
something like 'myCheckBox_1','myCheckBox_2', etc.?

If they are named in the above common manner, your code would then look
like: <cfif form['myCheckBox_' & i] eq 'on'>...</cfif>

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
Guest
Apr 01, 2008 Apr 01, 2008

Copy link to clipboard

Copied

I always forget about array notation. That made it work.

For the moment my checkboxes are named 1, 2, 3, ect... I wanted to make it work before I made it pretty.

Thanks tons.

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 ,
Apr 01, 2008 Apr 01, 2008

Copy link to clipboard

Copied

LATEST
Depending on your requirements, giving them all the same name and values of 1 through 58 could add simplicity and reduce processing 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
Resources
Documentation