Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

InnerHTML to call Javascript function

Posted on 2014-03-19
2
Medium Priority
?
835 Views
Last Modified: 2014-03-19
Hello,

I am building a string and insert the HTML in a DIV.  This code, gives the html below it.  The word "fast" shows up with hyperlink but the function getSyn never gets called when you click on it.  

Any help would be much appreciated!

Cheers,

thissyn = "<a onclick='getSyn("+strIn.data[0].nym+")' href='javascript:void(0);'>" + strIn.data[0].dictionary.definitionData[a].meanings[c].synonyms[d].nym + "</a>, ";

Open in new window


<a onclick='getSyn(fast)' href='javascript:void(0);'>fast</a>

Open in new window

0
Comment
Question by:1Cougar
[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
2 Comments
 
LVL 4

Accepted Solution

by:
Ersoy Hasan earned 2000 total points
ID: 39939301
It is because you are calling getSyn with fast directly (as a variable which do not exist) it should called as string "fast":
thissyn = "<a onclick='getSyn(\""+strIn.data[0].nym+"\")' href='javascript:void(0);'>" + strIn.data[0].dictionary.definitionData[a].meanings[c].synonyms[d].nym + "</a>, ";

Open in new window

<a onclick='getSyn("fast")' href='javascript:void(0);'>fast</a>

Open in new window

0
 

Author Comment

by:1Cougar
ID: 39939370
Perfect.  Thank you!

Cheers,
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

636 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