Solved

InnerHTML to call Javascript function

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how can i test my code? 1 39
Is there a way to use PhantomJS on a shared server? 4 17
add image on html mail 6 19
Html Table Looping (part 2) 5 8
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

809 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