Jump to content

Trouble Using Link to Execute Function


Selacius

Recommended Posts

I have this link:

 <a href=\"java script:void(0)\" onclick=\"useitem("+door[3]+")\"><b>Unlock</a><p/>;		

However, clicking the link does not execute the function. Anyone have an idea wat the problem could be?

Link to comment
Share on other sites

That code is malformed, what's with the backslashes and the addition operators inside the argument?

Link to comment
Share on other sites

I guess I should supply the full line of code to display the link on the page.

 $("console1").innerHTML += "<a href=\"java script:void(0)\" onclick=\"useitem("+door[3]+")\"><b>Unlock</a><p/>";

The addition operators are there because I need to supply the function with a value in order for it to do what I need.

Link to comment
Share on other sites

Have you tried running the function in the console? Also, try alerting a value right at the start of the function to check whether it really isn't being called, or is just not working.Also, if door[3] is a string, you'll need quotation marks around it (you can use single quotation marks).P.S. your closing paragraph tag is written the wrong way round, and you've got a stray boldface tag as well. (Interestingly enough, the lack of the closing boldface tag is only valid in SGML, while the way the paragraph tag is written, as an empty paragraph element, is only valid in XML.)

Link to comment
Share on other sites

I have tried to alert right at the start of the function (its actually the only line presently in the function), so it is most certainly not being called. I know I have a few tags that hang open and such. I'll finish up those once everything works. I figured it out, the single quotation marks were all i needed to fix it up:)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...