[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Passing a Coldfusion variable in an onClick function in href

Posted on 2011-03-02
6
Medium Priority
?
1,301 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
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…

649 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