ahmed salah

ahmed salah

  • NA
  • 530
  • 141k

how to increase value of like when click button like runtime

Aug 6 2016 8:37 AM
Hi I create web page have input type text and button add
when write value of course name in text box and press click add button it added in table as following
course    like   dislike
 
 c#             0          0        like  dislike
 
What i need actually is when press click on like button increase value of 0 for like  depend on how many time click i will press on button like
suppose i click like button 5 times click
it will start 1,2,until it reach to 5
 
c#    5    0    like dislike (press button like 5 times click) 
 
my code as bellow
  1. @{  
  2.     Layout = null;  
  3. }  
  4.   
  5. <!DOCTYPE html>  
  6.   
  7. <html>  
  8. <head>  
  9.     <meta name="viewport" content="width=device-width" />  
  10.     <title>Index</title>  
  11.     <script src="~/Scripts/jquery-1.10.2.js"></script>  
  12.     <script>  
  13.         $(function () {  
  14.             $("#btn").click(function () {  
  15.                 var x = $("#txt1").val();  
  16.                 var y = 0  
  17.                 var z= 0;  
  18.                 $("#tb").append("<tr> <td>" + x + "</td> <td>" + y + "</td> <td>" + z + "</td><td> <input type='button'class='c' value='Like'/></td><td> <input type='button' class='d' value='Dislike'/></td></tr>");  
  19.   
  20.   
  21.             });  
  22.         });  
  23.     </script>  
  24. </head>  
  25. <body>  
  26.     <div>   
  27. <input type="text" name="txt1" id="txt1" />  
  28. <input type="button" id="btn" value="add" />  
  29.         <table>  
  30.             <thead>  
  31.                 <tr>  
  32.                     <td>  
  33.                         Course  
  34.                     </td>  
  35.                     <td>  
  36.                         LikeAccount  
  37.                     </td>  
  38.                     <td>  
  39.                         DislikeAccount  
  40.                     </td>  
  41.                     <td>  
  42.                 </tr>  
  43.             </thead>  
  44.             <tbody id="tb"></tbody>  
  45.         </table>  
  46.     </div>  
  47. </body>  
  48. </html>  
 

Answers (2)