Skip to main content
September 14, 2010
Answered

How to have a dynamic variable name?

  • September 14, 2010
  • 1 reply
  • 459 views

I have a form that determines how many phone numbers a client has to edit by running a query against the database. The client can have anywhere from 0-3 phone numbers. I am assuming I can just wrap a CFOUTPUT QUERY tag around my input field so that it will loop if there are more than 1. What I can't figure out is how to dynamically name the input field within the CFOUTPUT tag for the UPDATE query I run after the user submits the form.

For example, if the query find that the user has 2 phone numbers in the table, how do I control their name?

<cfinput name="?" ..........>

<cfinput name="?2".........>

How can this be done dynamically within the cfoutput that is returning results of the query?

    This topic has been closed for replies.
    Correct answer ilssac

    <cfinput name="phone_#count#"...> did not acomplish your goal?

    1 reply

    ilssac
    ilssacCorrect answer
    Inspiring
    September 14, 2010

    <cfinput name="phone_#count#"...> did not acomplish your goal?

    tclaremont
    Inspiring
    September 14, 2010

    I presume you have an index number for each entry in your database. I would use that number, since you are assured it is unique.