I have a foreach to get messages in database,My code is here:
<form action="/Send/Message/Reply" method="POST" id="sendReply">
{{csrf_field()}}
<textarea class="text-right" cols="80" rows="5" id="messageReply">
</textarea>
<input type="hidden" value="{{$message->id}}" id="messageId">
<div class="footer text-right">
<button type="submit" class="S-products">Send</button>
</div>
</form>
Now I Want to get message id and Reply_Content in javascript with axios by this code:
(function()
{
document.querySelector('#sendReply').addEventListener('submit',function (e) {
var messageReply = document.querySelector('#messageReply').value;
var messageId = document.querySelector('#messageId').value;
console.log(messageId)
axios.post(this.action,{
'messageReply' : messageReply,
'messageId' : messageId,
'_token': $('input[name=_token]').val()
})
})
})();
Bu i get messageId as Undefined,How I can Fix this problem?