I have a php loop that generates several buttons.Each button changes the content of a specific div and update some stuff in the database by using an ajax request.When the button is click it calls a function that executes the ajax request.The problem is that I am not able to pass the Div id as parameter in the function if I concatenate it with a string. Only when I write $TickCrossDiv = $i it is working (only when using number as Div id it works).
Here is my code :
for($i=0;$i<count($PlanningArray);$i++){
$TickCrossDiv = 'tickCrossDiv'.$i;
echo "<button onclick=\"SetActDone(
".$PlanningArray[$i]'PlanID'].",
".$PlanningArray[$i]['ActID'].",
".$TickCrossDiv.")\" >
Mark as done</button>"
}
Here is the function :
function SetActDone(PlanID,ActID,DivID)
{
$.ajax({
type: "POST",
url: 'testAjax.php',
data: {PlanID:PlanID, ActID:ActID},
success: function(data) {
$("#" + DivID ).html('<p>Status: Done</p> <i style="color:greenyellow; " class="fa fa-check-circle fa-2x"></i>');
}
});
}
I am getting the error :
Uncaught Error: Syntax error, unrecognized expression: #object HTMLDivElement