Solved

InnerHTML to call Javascript function

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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
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…

688 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