traport
asked on
Passing a Coldfusion variable in an onClick function in href
I have an href
<a href="javascript:void(0);" onClick="showPopUp('curren tRTIID=#cu rrentRTIID #')">#fixe dDisplayNa me#</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!
<a href="javascript:void(0);"
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!
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(#curren tRTIID#)"> #fixedDisp layName#</ a></cfoutp ut>
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);"
Just wrap your CF variable around the <cfoutput> Tag
<a href="javascript:void(0);" onClick="showPopUp('currentRTIID=<cfoutput>#currentRTIID#</cfoutput>')"><cfoutput>#fixedDisplayName#</cfoutput></a>
ASKER
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('curren tRTIID=123 555')">Jan e Doe</a> , is not being carried into the div that showPopUp calls.
Thanks!
In other words, <a href="javascript:void(0);"
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you!!!
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#)