I have problem with onclick function
My link
<a id="reply" onclick="replyFunction({{$review->id}})"class="right-button">Reply</a>
Function:
function replyFunction(id){
$('#reply').closest('div').append( $('.replyform'));
$('.replyform').show();
$('.replyform').attr('action', "/reply/submit/" + id);
}
Somehow this doesnt work I am getting
(index):155 Uncaught ReferenceError: replyFunction is not defined at HTMLAnchorElement.onclick
I have included the file and it should work i think.
What I am trying to do is to pass id to the function. Basically a user presses reply button onclick function should send parent id and with javascript I should change form that user will fill action with the parent id so I get the right route (I am working with laravel).
P.S. If there is an easier way to do this that I am missing would be glad to hear it.
<script>function replyFunction(id){ }</script>replyFunction()within another function? Such as a jQuery document.ready event handler? If so, that's the problem. It needs to be at global level. Also note that usingon*event attributes is an outdated bad practice which should be avoided. Use unobtrusive event handlers instead.