Skip to main content
Participant
January 27, 2010
Question

help with display

  • January 27, 2010
  • 3 replies
  • 503 views

Hi All

I have a  page mm.cfm which displays 2 columns from a table in the database, and this page is being called as a template  from a main.cfm .

The columns that are being displayed in mm.cfm are tied to an mm_id in the database which used to be constant till now, the mm_id is being changed i.e,now mm_id can be 1, 2, 3, 4.

now I need to display in  the main.cfm these mm_ids as links so that when i click those links the data in the mm.cfm linked to that id needs to be displayed.

I am new to javscripting, please help me out with this task

thanks in advance

This topic has been closed for replies.

3 replies

BKBK
Community Expert
Community Expert
February 20, 2010

You could do something like this

main.cfm

=========

<cfloop from="1" to="4" index="idx">
<cfoutput><a href="javascript:ColdFusion.navigate('mm_id.cfm?id=#idx#', 'mainPageDiv')">id = #idx#</a></cfoutput><br>
</cfloop>

<!--- container to display query result from mm_id.cfm in the main page --->

<cfdiv name="pageDiv" id="mainPageDiv"></cfdiv>

mm_id.cfm

==========

<cfif isNumeric(url.id) and url.id EQ int(url.id)><!--- if an integer --->
    <cfquery name="qry" datasource="myDSN">
        select * from myTable
        where id = <cfqueryparam cfsqltype="cf_sql_integer" value="#url.id#">
    </cfquery>
   
    <!--- the data to be displayed, for example, dump  --->
    <cfdump var="#qry#">
</cfif>

Inspiring
February 17, 2010

If you don't mid working with CFML instead of JavaScript, in mm.cfm, you could do something like this:

<cfquery name="MyQuery" Datasource="MyDSN">

     SELECT     Column1, Column2, mm_id

     FROM     MyTable

</cfquery>

Then, you could do something like this:

<table align="center" border="0" cellpadding="3" cellspacing="3">
<tr>
     <td>
         <strong>
             mm_id
            </strong>
        </td>
        <td>
         <strong>
             Column1
            </strong>
        </td>
        <td>
         <strong>
             Column2
            </strong>
        </td>
    </tr>
    <cfoutput query="MyQuery">
     <tr>
            <td>
                  <a href="SomeDetailPage.cfm?mm_id=#mm_id#">#mm_id#</a>
            </td>
            <td>
                  #Column1#
            </td>
            <td>
                  #Column2#
            </td>
        </tr>
    </cfoutput>
</table>

I hope this makes sense...

   Dan

Inspiring
January 27, 2010

You don't need javascript.  On main.cfm, run a query to get the id's.  Then use cfoutput, query = that query, to attach the id's to the links.