The issue that I am having is that the "the_id" variable needs to be passed to the "deleteEntry()" function. I am able to successfully pass an integer with no quotes around it, but I am unable to pass any variable to the function. The error that I get when trying to pass a variable either in quotes or not in quotes is - "Uncaught ReferenceError: the_id is not defined at HTMLInputElement.onclick". Any suggestions as to where to the issue lies? Thanks in advance.
var the_id = $(this).parents('tr:first').find('td:nth(4)').text();
the_id = parseInt(the_id);
$("#indate").remove();
newDate = document.createElement("input");
newDate.setAttribute("type","text");
newDate.setAttribute("id","indate");
newDate.setAttribute("placeholder",dateText);
newDate.setAttribute("onfocus","(this.type='date')");
newDate.setAttribute("onblur","(this.type='text')");
$("#changeDateType").append(newDate);
$("#description").attr("placeholder",descriptionText);
$("#inamount").attr("placeholder",amountText);
if(bill == "1"){
$("#billcheck").prop("checked",true);
}
else {
$("#billcheck").prop("checked",false);
}
$("#submitBill").remove();
$("#deleteBill").remove();
$('#submitBillInfo').append('<input type="submit" id="submitBill" value="Submit" onclick="submitEntry()">');
$('#submitBillInfo').append('<input type="submit" id="deleteBill" value="Delete" onclick="deleteEntry(the_id)">');
$("#billForm").removeAttr("onsubmit");
}
}
function deleteEntry(nums){
alert(nums);
var c = confirm("Do you want to delete this item?");
if( c == true){
$(function(){
$.ajax({
type: 'POST',
url: '../Js/deleteData.php',
data: { data: nums },
});
});