Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. function searchByFields() {
  2.  
  3. var match = {};
  4. var $url = "?";
  5.  
  6. match["date"] = $("#date").val();
  7. match["time"] = $("#time").val();
  8. match["venue"] = $("#venue").val();
  9. match["competition"] = $("#competition").val();
  10. match["homeTeam"] = $("#homeTeam").val();
  11. match["awayTeam"] = $("#awayTeam").val();
  12. match["homeTeamAbbr"] = $("#homeTeamAbbr").val();
  13. match["awayTeamAbbr"] = $("#awayTeamAbbr").val();
  14. match["halfLength"] = $("#halfLength").val();
  15. match["playersNumber"] = $("#playersNumber").val();
  16. match["subsNumber"] = $("#subsNumber").val();
  17.  
  18.  
  19. if (match["date"])
  20. $url += "&date=" + match["date"];
  21. if (match["time"])
  22. $url += "&time=" + match["time"];
  23. if (match["venue"])
  24. $url += "&venue=" + match["venue"];
  25. if (match["competition"])
  26. $url += "&competition=" + match["competition"];
  27. if (match["homeTeam"])
  28. $url += "&homeTeam=" + match["homeTeam"];
  29. if (match["awayTeam"])
  30. $url += "&awayTeam=" + match["awayTeam"];
  31. if (match["awayTeamAbbr"])
  32. $url += "&awayTeamAbbr=" + match["awayTeamAbbr"];
  33. if (match["homeTeamAbbr"])
  34. $url += "&homeTeamAbbr=" + match["homeTeamAbbr"];
  35. if (match["halfLength"])
  36. $url += "&halfLength=" + match["halfLength"];
  37. if (match["playersNumber"])
  38. $url += "&playersNumber=" + match["playersNumber"];
  39. if (match["subsNumber"])
  40. $url += "&subsNumber=" + match["subsNumber"];
  41.  
  42. alert($url);
  43. $('table').empty();
  44.  
  45. $('table').append("<tr><td>"+"ID"+"</td>"
  46. +"<td>"+"Date"+"</td>"
  47. +"<td>"+"Time"+"</td>"
  48. +"<td>"+"Venue"+"</td>"
  49. +"<td>"+"Competition"+"</td>"
  50. +"<td>"+"Home"+"</td>"
  51. +"<td>"+"Away"+"</td>"
  52. +"<td>"+"Home abbr."+"</td>"
  53. +"<td>"+"Away abbr."+"</td>"
  54. +"<td>"+"Half length"+"</td>"
  55. +"<td>"+"№ of players"+"</td>"
  56. +"<td>"+"№ of subs"+"</td>"
  57. +"<td>"+"Edit"+"</td>"
  58. +"<td>"+"Delete"+"</td>"
  59. +"</tr>");
  60.  
  61. $.ajax({
  62. type: 'GET',
  63. url: '/api/match/byFields' + $url,
  64. data: $url,
  65. dataType: 'json',
  66. success: function (data) {
  67. $.each(data, function(index, element) {
  68. $('table').append($('<tr>'));
  69. $('table').append($('<td>', {
  70. text: element.id,
  71. }));
  72.  
  73. $('table').append($('<td>', {
  74. text: element.date,
  75. }));
  76. $('table').append($('<td>', {
  77. text: element.time,
  78. }));
  79. $('table').append($('<td>', {
  80. text: element.venue,
  81. }));
  82. $('table').append($('<td>', {
  83. text: element.competition,
  84. }));
  85. $('table').append($('<td>', {
  86. text: element.homeTeam,
  87. }));
  88. $('table').append($('<td>', {
  89. text: element.awayTeam,
  90. }));
  91. $('table').append($('<td>', {
  92. text: element.homeTeamAbbr,
  93. }));
  94. $('table').append($('<td>', {
  95. text: element.awayTeamAbbr,
  96. }));
  97. $('table').append($('<td>', {
  98. text: element.halfLength,
  99. }));
  100. $('table').append($('<td>', {
  101. text: element.playersNumber,
  102. }));
  103. $('table').append($('<td>', {
  104. text: element.subsNumber,
  105. }));
  106. $('table').append($('<td><button id="edit" type="button" onclick="edit()">Edit</button>'));
  107.  
  108. $('table').append($('<td><button id="delete" type="button" onclick="del()">Delete</button>'));
  109. $('table').append($('</tr>'));
  110. });
  111. }
  112. });
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement