Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Get list</title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- </style>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
- </head>
- <body>
- <div class="container">
- <div class="form-group">
- <form name="n">
- <label for="comment">Token:</label>
- <input type="text" class="form-control" id="token" value="">
- <label for="comment">ID Group:</label>
- <input type="text" class="form-control" id="idnhom" value="">
- </form>
- </div>
- <button type="button" onclick="validateForm();" class="btn btn-success">
- Lấy danh sách
- </button>
- <div class="form-group">
- <table class="table table-striped" id="table">
- <thead>
- <tr>
- <th>Stt</th>
- <th>Họ và tên</th>
- <th>Link facebook</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <script type="text/javascript">
- function validateForm()
- {
- var token=document.forms["n"]["token"].value;
- var idnhom=document.forms["n"]["idnhom"].value;
- if (token==null || token=="") {
- alert('Bạn không được bỏ trống ô nhập token!');
- }else{
- $.ajax({
- data: { token: token, idnhom: idnhom },
- url: 'a.php',
- method: 'POST', // or GET
- }).done(function(msg) {
- var arr_id = getFromBetween.get(msg,'":"','"');
- maxid=arr_id.length - 3;
- var table = document.getElementById("table");
- for(dem=0;dem <=maxid;dem++) {
- var row = table.insertRow(dem+1);
- var cell1 = row.insertCell(0);
- var cell2 = row.insertCell(1);
- var cell3 = row.insertCell(2);
- cell1.innerHTML = dem+1;
- $.ajax({
- url:'b.php',
- method:'POST',
- data:{token:token,id:arr_id[dem]}
- }).done(function(data){
- cell2.innerHTML =data;
- });
- cell3.innerHTML = '<a href="https://facebook.com/'+arr_id[dem]+'"target="_blank">'+'https://facebook.com/'+arr_id[dem]+'</a>';
- }
- });
- }
- }
- var getFromBetween = {
- results:[],
- string:"",
- getFromBetween:function (sub1,sub2) {
- if(this.string.indexOf(sub1) < 0 || this.string.indexOf(sub2) < 0) return false;
- var SP = this.string.indexOf(sub1)+sub1.length;
- var string1 = this.string.substr(0,SP);
- var string2 = this.string.substr(SP);
- var TP = string1.length + string2.indexOf(sub2);
- return this.string.substring(SP,TP);
- },
- removeFromBetween:function (sub1,sub2) {
- if(this.string.indexOf(sub1) < 0 || this.string.indexOf(sub2) < 0) return false;
- var removal = sub1+this.getFromBetween(sub1,sub2)+sub2;
- this.string = this.string.replace(removal,"");
- },
- getAllResults:function (sub1,sub2) {
- // first check to see if we do have both substrings
- if(this.string.indexOf(sub1) < 0 || this.string.indexOf(sub2) < 0) return;
- // find one result
- var result = this.getFromBetween(sub1,sub2);
- // push it to the results array
- this.results.push(result);
- // remove the most recently found one from the string
- this.removeFromBetween(sub1,sub2);
- // if there's more substrings
- if(this.string.indexOf(sub1) > -1 && this.string.indexOf(sub2) > -1) {
- this.getAllResults(sub1,sub2);
- }
- else return;
- },
- get:function (string,sub1,sub2) {
- this.results = [];
- this.string = string;
- this.getAllResults(sub1,sub2);
- return this.results;
- }
- };
- </script>
- </tr>
- </tbody>
- </table>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment