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

Using Content of 1 variable as an other variable name!!!!

Guest
Dec 24, 2011 Dec 24, 2011

Copy link to clipboard

Copied

Hi

I have a big problem with my codes , i need to make some check box but i dont know how many i need at the first , the number of check box pass from other page to me and case to case is different.

so i try to make them by <cfloop> :

<cfset sdate="2011/01/01">

<cfset edate="2011/01/10">

<cfset TotalDays=(day(edate)-day(sdate))>

       <form name="hasankachal" action="dtest.cfm" method="post" enctype="multipart/form-data">

   

        <cfloop index="daylist" from="0" to="#totaldays#">

            <input type="checkbox" name="D<cfoutput>#daylist#</cfoutput>"><cfoutput>#day(dateadd("D",daylist,dateformat(sdate,"YYYY/MM/DD")))# #dateformat(sdate,"mmm")#</cfoutput><BR>

        </cfloop>

            <input type="hidden" name="sdate" value="<cfoutput>#sdate#</cfoutput>">

            <input type="hidden" name="edate" value="<cfoutput>#edate#</cfoutput>">

            <input type="hidden" name="totaldays" value="<cfoutput>#totaldays#</cfoutput>">

            <br>

            <input type="submit" name="test" value="Submit">

    </form>

in this case for example i need 10 check box so by this methode i will make D0,D1,D2, . . . .

the problem started from now , becasue the name of check boxes in <input> made by <cfloop> i need to read it by cfloop again :

    <cfloop index="daylist" from="0" to="#form.totaldays#">

            <cfif  FORM.?????????  is "on">

                <cfoutput>#day(dateadd("D",daylist,dateformat(sdate,"YYYY/MM/DD")))# #dateformat(sdate,"mmm")#</cfoutput><BR>

            </cfif>

    </cfloop>

i try to put the name of variable in othe variable :

<cfset mycheckbox="form.d"&daylist>

     <cfif #mycheckbox# is "on">

          <cfoutput>Selected</cfoutput>

     </cfif>

but its not working , is there any idea how can i make it and check it ?

TOPICS
Advanced techniques

Views

548

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 ,
Dec 24, 2011 Dec 24, 2011

Copy link to clipboard

Copied

form["staticPart" & 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
Guest
Dec 25, 2011 Dec 25, 2011

Copy link to clipboard

Copied

LATEST

Dear Dan,

Thanks a lot, you same my  a s s  man

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