I am trying to delete by ID. But why don't show action=NaN
in console.
Deleting.. form id="deletecategoryform" action="NaN" method="POST"
Here is my code
<script>
function handleDelete(id){
var form = document.getElementById('deletecategoryform')
form.action = '/categories/' * id
console.log('Deleting',form)
$('#deleteModal').modal('show')
}
</script>
My Answer:
The issue in your code is with the line `form.action = '/categories/' * id`. The `*` operator is used for multiplication in JavaScript, not for concatenating strings.
You should use the `+` operator to concatenate the strings like this:
javascript
form.action = '/categories/' + id;
This will properly set the action attribute of the form to the correct URL with the specific ID.
Rate this post
4 of 5 based on 7502 votesComments