Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Pass Coldfusion [columnName][currentRow] to javascript variable

Posted on 2011-02-24
1
Medium Priority
?
587 Views
Last Modified: 2012-05-11
Hi,

If I loop through a query of customers and I click on the third customer (for example) in the loop, how can I pass that customerID to a javascript variable?

I know I'm missing something basic here..

My code is below.

Thank you!
<script>
	function getCustomerID(){
	
	var myCustomerID= 'the customer id I want from the row I clicked on';

	}
</script>

<cfloop query="getCustomers">
  <cfoutput>
  <tr>
    <td>#customerID#</td>
    <td>#firstName#</td>
    <td>#lastName#</td>
    <td>#emailAddress#</td>
    <td><a style="cursor:pointer; text-decoration:underline; "onclick="getCustomerID()">edit</a></td>
  </tr>
  </cfoutput>
  </cfloop>

Open in new window

0
Comment
Question by:tomhwtt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
tomhwtt earned 0 total points
ID: 34975902
DOH!  I figured it out.
<script>
	function getCustomerID(x){
	
	var myCustomerID= x;

	}
</script>

<cfloop query="getCustomers">
  <cfoutput>
  <tr>
    <td>#customerID#</td>
    <td>#firstName#</td>
    <td>#lastName#</td>
    <td>#emailAddress#</td>
    <td><a style="cursor:pointer; text-decoration:underline; "onclick="getCustomerID(#customerID#)">edit</a></td>
  </tr>
  </cfoutput>
  </cfloop>

Open in new window

0

Featured Post

How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question