Solved

Pass Coldfusion [columnName][currentRow] to javascript variable

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now