while(rs.next()) { String friendname = rs.getString(2); out.print("<table><tbody><tr><td>"+rs.getString(2)); out.print(" <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>"); out.print(" <script src=\"js/index.js\"></script>"); // out.print("<button type=\"button\" onclick=friendnamebtn() id=\"btn_friends\">"); // out.print("<button type=\"button\" onclick='javascript:return friendnamebtn(this)' id=\"btn_friends\">"); out.print("<button type=\"button\" onclick='javascript:return friendnamebtn("+ friendname +")' id=\"btn_friends\">"); out.print("Add" + friendname); out.print("</button>"); out.print("</td></tr></tbody></table>"); } out.print(""); javascript code function friendnamebtn(friendname){ // var friends = document.getElementById("btn_friends"); alert(friendname+"add"); }
friendname
onclick
rs.getString(2)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)