function takeaction(id,tr,i,form){
if (window.confirm("Do you want to mark this record ? ")) {
var form = getElementById(form);
var element = document.getElementById(tr);
element.classList.remove("table-danger");
element.classList.add("table-success");
var element = document.getElementById(id);
element.remove(id);
var element = document.getElementById(i);
element.classList.add("fa-check");
form.submit();
} else {
return 0;
}
}
<table class="table table-hover">
<thead class="thead-dark">
<h1>Notifications</h1>
<tr>
<th>Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr id='tr4' class='table-danger'>
<td>Geethan</td>
<td>
<form action='include/action.php?user_id=4' method='post' id='form' >
<input id='tr4_btn' class='btn btn-warning' type='submit' name='action1' value='Take action' onclick="takeaction(this.id ,'tr4','tr4_i','form')" />
<i id="tr4_i" class="fa " style="color:green;"></i>
</form>
</td>
</tr>
when I tried to submit this form and change the class names by using js function "onclick="takeaction(this.id ,'tr4','tr4_i','form')" the form is submitted but class names are not changed. I want to do both these processes at once