Guest User

Untitled

a guest
Jan 6th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.40 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Get list</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  8. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  9. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  10. </style>
  11. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  12. </head>
  13. <body>
  14. <div class="container">
  15. <div class="form-group">
  16. <form name="n">
  17. <label for="comment">Token:</label>
  18. <input type="text" class="form-control" id="token" value="">
  19. <label for="comment">ID Group:</label>
  20. <input type="text" class="form-control" id="idnhom" value="">
  21. </form>
  22. </div>
  23. <button type="button" onclick="validateForm();" class="btn btn-success">
  24. Lấy danh sách
  25. </button>
  26. <div class="form-group">
  27. <table class="table table-striped" id="table">
  28. <thead>
  29. <tr>
  30. <th>Stt</th>
  31. <th>Họ và tên</th>
  32. <th>Link facebook</th>
  33. </tr>
  34. </thead>
  35. <tbody>
  36. <tr>
  37. <script type="text/javascript">
  38.  
  39. function validateForm()
  40. {
  41. var token=document.forms["n"]["token"].value;
  42. var idnhom=document.forms["n"]["idnhom"].value;
  43.  
  44. if (token==null || token=="") {
  45. alert('Bạn không được bỏ trống ô nhập token!');
  46. }else{
  47. $.ajax({
  48. data: { token: token, idnhom: idnhom },
  49. url: 'a.php',
  50. method: 'POST', // or GET
  51. }).done(function(msg) {
  52. var arr_id = getFromBetween.get(msg,'":"','"');
  53. maxid=arr_id.length - 3;
  54. var table = document.getElementById("table");
  55. for(dem=0;dem <=maxid;dem++) {
  56. var row = table.insertRow(dem+1);
  57. var cell1 = row.insertCell(0);
  58. var cell2 = row.insertCell(1);
  59. var cell3 = row.insertCell(2);
  60. cell1.innerHTML = dem+1;
  61. $.ajax({
  62. url:'b.php',
  63. method:'POST',
  64. data:{token:token,id:arr_id[dem]}
  65. }).done(function(data){
  66. cell2.innerHTML =data;
  67. });
  68. cell3.innerHTML = '<a href="https://facebook.com/'+arr_id[dem]+'"target="_blank">'+'https://facebook.com/'+arr_id[dem]+'</a>';
  69. }
  70. });
  71. }
  72.  
  73. }
  74. var getFromBetween = {
  75. results:[],
  76. string:"",
  77. getFromBetween:function (sub1,sub2) {
  78. if(this.string.indexOf(sub1) < 0 || this.string.indexOf(sub2) < 0) return false;
  79. var SP = this.string.indexOf(sub1)+sub1.length;
  80. var string1 = this.string.substr(0,SP);
  81. var string2 = this.string.substr(SP);
  82. var TP = string1.length + string2.indexOf(sub2);
  83. return this.string.substring(SP,TP);
  84. },
  85. removeFromBetween:function (sub1,sub2) {
  86. if(this.string.indexOf(sub1) < 0 || this.string.indexOf(sub2) < 0) return false;
  87. var removal = sub1+this.getFromBetween(sub1,sub2)+sub2;
  88. this.string = this.string.replace(removal,"");
  89. },
  90. getAllResults:function (sub1,sub2) {
  91. // first check to see if we do have both substrings
  92. if(this.string.indexOf(sub1) < 0 || this.string.indexOf(sub2) < 0) return;
  93.  
  94. // find one result
  95. var result = this.getFromBetween(sub1,sub2);
  96. // push it to the results array
  97. this.results.push(result);
  98. // remove the most recently found one from the string
  99. this.removeFromBetween(sub1,sub2);
  100.  
  101. // if there's more substrings
  102. if(this.string.indexOf(sub1) > -1 && this.string.indexOf(sub2) > -1) {
  103. this.getAllResults(sub1,sub2);
  104. }
  105. else return;
  106. },
  107. get:function (string,sub1,sub2) {
  108. this.results = [];
  109. this.string = string;
  110. this.getAllResults(sub1,sub2);
  111. return this.results;
  112. }
  113. };
  114. </script>
  115. </tr>
  116. </tbody>
  117. </table>
  118. </div>
  119. </body>
  120. </html>
Advertisement
Add Comment
Please, Sign In to add comment