?
Solved

Passing a Coldfusion variable in an onClick function in href

Posted on 2011-03-02
6
Medium Priority
?
1,255 Views
Last Modified: 2012-05-11
I have an href

<a href="javascript:void(0);" onClick="showPopUp('currentRTIID=#currentRTIID#')">#fixedDisplayName#</a>

and it controls the show/hide of a lightbox.

I can't get the variable #currentRTIID# to pass in the function I'm using. Either that or I can't get the page it passes to (which is actually just showing/hiding a div.

Help!

0
Comment
Question by:traport
[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
6 Comments
 
LVL 3

Expert Comment

by:sajayc
ID: 35022913
Hi,
This should work,
You will need to put <cfoutput></cfoutput> tags around that line your code for the variables to be resolved.

Otherwise the variables will be sent to your browser with the hashes (#variable#)
0
 
LVL 3

Expert Comment

by:sajayc
ID: 35022965
Sorry, I just realised that when you pass variables into javascript, you only need to send the value.

If you publish you javascript function, I can check that you are retrieving the value correctly.

Javascript should look something like this:

function showpopup(lvcurrentrtiid)
{
The variable lvcurrentrtiid is what you use to do whatever you need to do.
}


Link should look like this:
<cfoutput><a href="javascript:void(0);" onClick="showPopUp(#currentRTIID#)">#fixedDisplayName#</a></cfoutput>



0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 35023310
Just wrap your CF variable around the <cfoutput> Tag

<a href="javascript:void(0);" onClick="showPopUp('currentRTIID=<cfoutput>#currentRTIID#</cfoutput>')"><cfoutput>#fixedDisplayName#</cfoutput></a>

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:traport
ID: 35025948
Thanks for the help but that's actually not the problem I'm having (apologies if I confused you). The problem I'm having is that the variable (which I can see in the link) is not carrying over to the hidden div when the link is clicked.

In other words, <a href="javascript:void(0);" onClick="showPopUp('currentRTIID=123555')">Jane Doe</a> , is not being carried into the div that showPopUp calls.

Thanks!

0
 
LVL 3

Accepted Solution

by:
dagaz_de earned 2000 total points
ID: 35028438
You have aProblem in your JS Syntax:

If you pass 2 Values to a JS function you must seperate them with a comma, not a '='.

showPopUp('currentRTIID=123555') is false

showPopUp('currentRTIID','123555') is good

in your JS you do it like this



function showPopUp ( param, val){

// now you can use param which holds the first value you submitted to Your JS function ( currentRTIID)

// and second you can use val which holds the first value you submitted to Your JS function ( 123555)

var theurl = 'http://your-url.com/your-page.cfm?' + param + '=' + val + '';

window.open(""+theurl +"", "YourWindowName", "width=300,height=400,left=100,top=200");

}
0
 

Author Closing Comment

by:traport
ID: 35032850
Thank you!!!
0

Featured Post

TCP/IP Network Protocol Cheat Sheet

TCP/IP is a set of network protocols which is best known for connecting the machines that make up the Internet. The truth is that TCP/IP is one of the oldest network protocols and its survival is mainly based on its simplicity and universality.

Question has a verified solution.

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

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
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…
Suggested Courses

752 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