<script type="text/javascript">
function toEdit(id,f,t,dis) {
alert(id);
alert(dis);
alert(f);
alert(t);
}
but alert is not working And I think probably it’s not working due to this unexpected “Quotations”
This is unexpected Quotation Image in inspect Element
This scheme works well for me. I create a JSON encoded array of values and embed that as data attribute of the clickable button, so that Java can parse that array. In your case there is already an array $row that can be encoded and passed:
$row_json = htmlspecialchars(json_encode($row));
echo '<button id = "edit_button" data-json = "'.$row_json.'" class = "prettyclass">Edit</button>";
and then in Java --I’m in WP so I use jquery–
jQuery(document).ready(function ($) {
$(document).on('click', '#edit_button', function(e){
e.preventDefault();
$(this).css({opacity:0.3});
id = parseInt($(this).data('json').id, 10)
alert('id = '+id);
dis = $(this).data('json').dis;
// or to reference it anywhere...
dis = $('#edit_button').data('json').dis
alert('dis string is '+dis);
});
});