I have the following code that creates multiple different forms within a for loop to delete the different values in a database:
@foreach (var item in Model.value)
{
<script>var temp = {'value' : '@item.name'}</script>
<form class="formStyle" id="allCurrentNames_@item.name" method="post" action="">
<input type="hidden" id="part_name_@item.name" value="@item.name"/>
<button class="partDelete" onclick="deletePart(temp);return false;">Delete</button>
</form>
}
The following is the deletePart(temp) function:
function deletePart(temp) {
var personName = $("input#part_num_"+temp.value).val();
var dataString = 'partnumber=' + partnumber;
$.ajax({
AJAX STUFF
})
}
Assuming I will have something like the following:
Person Name1 [DELETE]
Person Name2 [DELETE]
Person Name3 [DELETE]
Person Name4 [DELETE]
Person Name5 [DELETE]
Person Name6 [DELETE]
If I click Person Name3 it sends in the value of Person Name6 always no matter which Delete button I click.
Any help is much appreciated! Thank you for your time!