Chalkie83

Untitled

Oct 30th, 2021
38
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>  
  2.  $(document).ready(function(){  
  3.       var i=1;  
  4.       $('#add').click(function(){  
  5.            i++;  
  6.            $('#dynamic_field').append('<tr id="row'+i+'"><td><? echo $teamdrophome; ?></td><td><? echo $teamdropaway; ?></td><td><input type="text" name="postponed[]" placeholder="Type true if game is postponed" class="form-control name_list" /></td><td><input type="datetime-local" name="datetime[]" class="form-control name_list" ></td><td><input type="text" name="location[]" placeholder="Location" class="form-control name_list" /></td><td><button type="button" name="remove" id="'+i+'" class="btn btn-danger btn_remove">X</button></td></tr>');  
  7.       });
  8.      $(document).on('click', '.btn_remove', function(){  
  9.            var button_id = $(this).attr("id");  
  10.            $('#row'+button_id+'').remove();  
  11.       });  
  12. });  
  13. </script>
  14. <script>
  15. function formatTeams (data) {
  16.     if(!data.id) { return data.text; }
  17.     var baseUrl = "/images/badges";
  18.     imageString = data.element.text.toLowerCase();
  19.     newImageString = imageString.replace(/ /g, "_");
  20.     var $result = $(
  21.     '<span style="min-width:150px;"><img src="' + baseUrl + '/' + newImageString + '.png" class="fwsbadge" style="width:30px!important;float:left;"/><br> ' + data.text + '</span>'
  22.     );
  23.     return $result;
  24. };
  25.  
  26. $("#home").select2( {
  27.     placeholder: "Search Teams",
  28.     allowClear: true,
  29.     templateResult: formatTeams
  30. });
  31.  
  32. $("#away").select2( {
  33.     placeholder: "Search Teams",
  34.     allowClear: true,
  35.     templateResult: formatTeams
  36. });
  37. </script>
RAW Paste Data