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
Solved

Pass Coldfusion [columnName][currentRow] to javascript variable

Posted on 2011-02-24
1
576 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
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

829 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