Pass 2 values to a Function for the onClick event

Asked

Viewed 400 times

0

Good afternoon guys, wanted to know how I step 2 values for a Function, I expect to send an id and the message. I did reading some forums on the net, but it’s not working.

<a  href="#" onClick="answer('+ objeto.idForum +',' objeto.message')" id="answer" >Responder</a>    

function answer(id, mensagem) {
    alert(id);
    alert(mensagem);
}
  • I ran the same code in Codepen and ran colleague. Open the Developer console and see if there is an error together that does not perform the function, or something like that. If you copy this snippet to a jsfiddle vera that is ok.

  • thanks Bruno, I’ll take a look at the console, thank you very much.

  • Where this object comes from objeto?

  • id comes from the bank, which is from a question, and the message would be the relevant answer to the question.

  • but this objeto is in the global space? where is the code? it would be interesting to show, you will have more interesting answers

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.