I'm trying to make script with JavaScript which is dynamic, yes I know, JavaScript is always dynamic but I want to do in combination with PHP.
JS:
$(document).ready(function(){
$("#glcheckmail").click(function(){
$("#glmaildiv").load('/functions/glist-MailChecker.php');
});
});
PHP:
echo "<div class=\"list-group-item\" data-toggle=\"modal\" href=\"#\"><span class=\"badge badge-danger\"><a href=\"#\" class=\"donothover\">Delete</a></span>
<div style=\"white-space:nowrap; overflow:hidden; text-overflow:ellipsis; width:80%;\">". $row['attach_name'] ." (<i>". formatSizeUnits($row['attach_size']) ."</i>)</div></div> ";
As you can see I have an "<a href="">"
with Delete in it. What I'm trying to accomplish is actually something like this (Example Not Real Code!)
<a href="#" id="RefToJS" onclick="<? echo $attach_id; ?>">
Now (hypothetically) my JavaScript should see a variable in #RefToJS
. And I want to pass this variable on to the PHP script which loads onclick
, like this
$(document).ready(function(){
$("#glcheckmail").click(function(){
$("#glmaildiv").load('/functions/glist-MailChecker.php?id='+ONCLICK_CODE);
});
});
This is sort of what I want but as you can see, the code isn't a beauty and I have to little knowledge of JavaScript to make this work