Click here to Skip to main content
15,905,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
am write a code like below in this how to adding delete button

XML
var tableContents = "";
            tableContents += "<div style='max-height: 400px; overflow:auto;'>";
            tableContents += "<table id='recsTable' border=1>";
            tableContents += "<tr>";
            tableContents += "<th bgcolor='gray'>";
            tableContents += "Name";
            tableContents += "</th>";
            tableContents += "<th bgcolor='gray'>";
            tableContents += "CourseName";
            tableContents += "</th>";
            tableContents += "<th bgcolor='gray'>";
            tableContents += "CollegeName";
            tableContents += "</th>";
            tableContents += "</tr>";

         for (i = 0; i < retrivemultiple.length; i++)
          {
                tableContents += "<tr>";
                tableContents += "<td>" + dataName[i] + "</td>";
         tableContents += "<td>" + dataCourse[i] + "</td>";
         tableContents += "<td>" + dataCollege[i] + "</td>";
         <button id="btndelete" text="DELETE"/>;
                tableContents += "</tr>";
           }
            tableContents += "</table>";
            tableContents += "</div>";
            document.getElementById('tableSpace').innerHTML = tableContents;
Posted
Comments
JR009 20-Jan-15 2:08am    
Where you want to add Delete button in table?
Sinisa Hajnal 20-Jan-15 2:24am    
What is the question? You have btnDelete in there.

1 solution

Here is your error :
HTML
<button id="btndelete" text="DELETE" />;

this line should be wrapped inside quotes.

here is the correct code :

replace above line with :

HTML
tableContents += "<td><button id='btndelete_"+ i + "' text='DELETE'>Delete</button></td>";


Good luck.
 
Share this answer
 
v2
Comments
Member 11387257 20-Jan-15 4:42am    
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900