2 Replies Latest reply on Dec 25, 2011 7:02 AM by Ali Parsa

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

    Ali Parsa

      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(sdat e,"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 ?