0

Hi,

I am trying to do something like this:

function showContent(toPopulate) { 
      document.getElementById(toPopulate).innerHTML = "<a href='javascript:showOtherContent(toPopulate);'>show</a>" 
}

function showOtherContent(toPopulate) {...}

I am not able to send the variable toPopulate as an argument of function showOtherContent() in line 2

Thanks,

Blaise

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by Blaise.M
0
function showContent(toPopulate)
{ 
document.getElementById(toPopulate).innerHTML = "<a href='javascript:showOtherContent(\"toPopulate\");'>show</a>" 
}

function showOtherContent(toPopulate) {alert(toPopulate)}

Above is working

0
function showContent(toPopulate)
{ 
document.getElementById(toPopulate).innerHTML = "<a href='javascript:showOtherContent(\"toPopulate\");'>show</a>" 
}

function showOtherContent(toPopulate) {alert(toPopulate)}

Above is working

mahavir123,

showOtherContent(\"toPopulate\"); will send toPopulate as a string, and therefore alert(toPopulate) will print the string "toPopulate" and not the content of function argument - toPopulate. I need the content of toPopulate ...

0

Try this one:

document.getElementById(toPopulate).innerHTML = "<a href='javascript:showOtherContent(\"" + toPopulate + "\");'>show</a>"

Hope this help.

0

Try this one:

document.getElementById(toPopulate).innerHTML = "<a href='javascript:showOtherContent(\"" + toPopulate + "\");'>show</a>"

Hope this help.

It works. This is the solution.

Thanks Zero13

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.