Skip to main content
Participant
June 4, 2009
Question

How to access the form items dynamically

  • June 4, 2009
  • 1 reply
  • 407 views

The issue here is that I want to acces the value in the textboxes dynamically



Here is the code ( I know its wrong )



<cfset temp = TaskEntryIDs.Split(',') />



    <cfloop index="x" from="1" to="#arrayLen(temp)#">
   
    <cfset TempControl = "Form.t"&temp>
    <cfif isdefined("Form.t"&temp)>
         <cfoutput>#"Form.t"&temp#</cfoutput><br/>
    </cfif>
    </cfloop>



I don't know the correct way to access it, I know that the textbox name start with T and the task number



I know that the textbox for the task number 74 is t74, but how can I access the value of this text box so I can insert it into to the database ?



Please help me



Thanks

This topic has been closed for replies.

1 reply

ilssac
Inspiring
June 4, 2009

Array Notation:

Form["t" & temp]

StuctKeyExists() is an easier function to determine dynamic form fields exist.

<cfif structKeyExists(form,"t" & temp)>  rather then isDefined().