I want to create new buttons using a single button, and after creating those new buttons, I want to click on them and have their id number sent to the php file.
my code:
<script>
var count=1;
document.getElementById("btn").onclick=function(){
document.getElementById("col").innerHTML+="<tr><td><button type='submit' name='id' id='clickable'>"+count+"</button></td></tr>";
var cid=count;
$("#clickable").click(function(){
location.href="trial29.php?id="+cid;
});
count++;
}
</script>
The problem is that I'm not able to make more than one button clickable. Also I'm not able to set the id of the button to the value they have on them.
idis a unique identifier. Having a lot of items with same id means that only first one will be considered.