Solved

InnerHTML to call Javascript function

Posted on 2014-03-19
2
753 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

939 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

6 Experts available now in Live!

Get 1:1 Help Now