Solved

Pass Coldfusion [columnName][currentRow] to javascript variable

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
Suggested Courses

623 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