Skip to main content
January 13, 2008
Question

How to evalute a cfselect

  • January 13, 2008
  • 2 replies
  • 449 views
I am just learning how to do a cfloop to insert my values into database. I have a cfform that is working great but now I need to add a cfselect.

How can I make the following

<cfinput type="text" name="tasktype#idx#" value="#evaluate("form.tasktype#idx#")#" size="5" maxlength="5">

reference a cfselect like this

<cfselect name="tasktype" query="jobtypes" value="jobtypevalue" display="jobtype"></cfselect>

is it possible?

Thanks Sue
    This topic has been closed for replies.

    2 replies

    Inspiring
    January 14, 2008
    Are you sure you are looking for the value and not the selected attribute? If you wanting to assign something to the value attribute, all options will have the same value which kind of defeats the purpose of a select.
    Inspiring
    January 13, 2008
    What sort of reference did you have in mind? If the loop for your text boxes is coming from the jobtypes query, the select is redundant.
    January 13, 2008
    I am still learning how to do cfloops and found a tutorial on easycfm.com.

    Basically the form works like the following.
    <cfloop from="1" to="#getnumba#" index="idx">
    <!--- At first, it displays the original one row form --->
    <!--- User enters the data and hits "Add Another" --->
    <!--- The page reloads with the data already entered and creates a new blank row that is ready for data entry --->

    The field that I am trying to use a cfselect on is the following:
    <tr>
    <cfif isdefined ("form.tasktype#idx#")>
    <Td class="two"><cfinput type="text" name="tasktype#idx#" value="#evaluate("form.tasktype#idx#")#" size="5" maxlength="5"></TD>
    <cfelse>
    <Td class="two"><cfinput type="text" name="tasktype#idx#" size="5" maxlength="5"></TD>
    </cfif>

    so I want to change it from a cfinput type text to a cfselect from a query. I am confused on what to put on the value. I have tried to use the following but iof course t does not loop.

    <cfselect name="tasktype" query="jobtypes" value="jobtypevalue" display="jobtype"></cfselect>

    so I tried this

    <cfif isdefined ("jobtypes.tasktype#idx#")>
    <cfselect name="tasktype#idx#" query="jobtypes" value="#evalute(jobtypes.jobtypevalue#idx#)#" display="jobtype"></cfselect>
    <cfelse>
    <cfinput type="text" name="tasktype#idx#" size="5" maxlength="5">
    </cfif>