Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
74
rated 0 times [  76] [ 2]  / answers: 1 / hits: 22677  / 12 Years ago, wed, july 4, 2012, 12:00:00

I am having issues passing a dynamic parameter to a JavaScript function using innerHTML.



Included below is the current code that I am using:



var name = test;

frm.innerHtml = '<button name=close id=close title=Cancel type=button
onclick=closeTab('+name+');>Return</button>';


When I debug the code of the closeTab() function, the parameter specified by the name variable is null.



I believe there is a problem with the declaration of the value while modifying the innerHTML property.



Any help would be greatly appreciated.



Thanks


More From » html

 Answers
24

I simply used onclick=closeTab(name);> in innerHTML and it worked. I guess that worked coz name is global variable.


[#84486] Monday, July 2, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mariann

Total Points: 201
Total Questions: 133
Total Answers: 107

Location: Czech Republic
Member since Thu, Aug 11, 2022
2 Years ago
;