I have a list of buttons on a page that is created using a database, I would like to disable the user click button permanently. Button should be in diable mode after page load too.
<div class="panel-group" id="posts">
<?php
while($row = $query->fetch(PDO::FETCH_ASSOC))
{
?>
<button id='registedButton' type='button' onclick='getButtonDataId(this)' data-id=<?php echo $row["Acronym"]; ?>>Applied</button>
}
<div class="panel-group" id="posts">
<?php
while($row = $query->fetch(PDO::FETCH_ASSOC))
{
?>
<button id='registedButton_<?php echo $row["Acronym"]; ?>' type='button' class="registedButton" data-id=<?php echo $row["Acronym"]; ?>>Applied</button>
<?php } ?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".registedButton").each(function() {
var getCookieName = $(this).attr('id');
if(getCookie(getCookieName)){
$(this).prop('disabled',true);
}
});
});
$('.registedButton').on('click', function(e) {
var cookieName = $(this).attr('id');
var eCookie = setCookie(cookieName, 'setVal');
e.preventDefault();
$(this).prop('disabled',true);
});
</script>