php - Javascript event for table cell generated by AJAX -
this question has answer here:
i printing rows in talbe follows. when btndes cell clicked, able captuer variable java script.
when same table printed via ajax, same javascript code not able capture event , variables.
can tell me how this?
$counter = 0; while ($row = $db->getassocarr($results)) { ?> <form action="form.php" method="post" id="form-<?php echo $counter; ?>" enctype="multipart/form-data"> <tr> <td><?php echo $row['name']; ?> <input type="hidden" value = "<?php echo $row['projid']; ?>" name="projid"/> </td> <td><a href="#" name="btndes">design</a> | </td> </tr> </form> <?php $counter++; }
java script
designbtn = document.getelementsbyname("btndes"); (var = 0; < designbtn .length; i++) { designbtn [i].id = i; designbtn [i].onclick = fdesign; }
i had same issue, used jquery handle it. set class name, try might helpful
$(document).ready(function () { $('body').on('click', '.btndes', function (){ var designbtn = $(.btndes).val(); (var = 0; < designbtn .length; i++) { designbtn [i].id = i; designbtn [i].onclick = fdesign; } }
Comments
Post a Comment