Skip to main content
Inspiring
December 1, 2011
Question

How to generate unique table row id's in a cfoutput query?

  • December 1, 2011
  • 1 reply
  • 744 views

I am trying to implement a jQuery drag and drop table row function to my CF pages but in order to save my "drop" positioning to the database I need to serialize all the table row id's.What coding would I need to add so that after the cfoutput query is run, each table row would have a unique id (ie. tr id="1", tr id="2", etc.)? Thanks.

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    December 1, 2011

    Utilize the CurrentRow variable that's automatically available within your query output:


    <cfoutput query="myQry">

              <tr id="row#currentRow#">

                        <td>...</td>

              </tr>

    </cfoutput>


    that will give you:


    <tr id="row1">

              <td>...</td>

    </tr>

    <tr id="row2">

              <td>...</td>

    </tr>

    <tr id="row3">

              <td>...</td>

    </tr>

    etc...

    Inspiring
    December 1, 2011

    JMF has it right.  In case you were not familiar with cfquery's currentRow property, I recommend you take a look at the <cfquery> documentation page that outlines some of the additional properties you have available to you when using <cfquery>:

    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7fae.html