jp112

JSPost

Apr 1st, 2020
493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.        function GoBtn() {
  2.          var sftext='';
  3.  
  4.          for (var i = 1; i < 7; i++) {
  5.            var l  = document.getElementById("textline"+i).value;
  6.            if (l.length > 0) {
  7.              sftext+=l+';';
  8.            }
  9.          }
  10.          
  11.          console.log(sftext);
  12.          post('/', {textlist: sftext});
  13.        }
  14.        
  15.        function post(path, params, method='post') {
  16.          const form = document.createElement('form');
  17.          form.method = method;
  18.          form.action = path;
  19.  
  20.          for (const key in params) {
  21.            if (params.hasOwnProperty(key)) {
  22.              const hiddenField = document.createElement('input');
  23.              hiddenField.type = 'hidden';
  24.              hiddenField.name = key;
  25.              hiddenField.value = params[key];
  26.  
  27.              form.appendChild(hiddenField);
  28.            }
  29.           }
  30.  
  31.           document.body.appendChild(form);
  32.           form.submit();
  33.        }
Advertisement
Add Comment
Please, Sign In to add comment