Solved

InnerHTML to call Javascript function

Posted on 2014-03-19
2
740 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
2 Comments
 
LVL 4

Accepted Solution

by:
Ersoy Hasan earned 500 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now