Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Pass Coldfusion [columnName][currentRow] to javascript variable

Posted on 2011-02-24
1
Medium Priority
?
589 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…

876 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