Advertisement
GWibisono

convert excel to parameter HTML

Jun 13th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.88 KB | None | 0 0
  1. <html>
  2.   <head>
  3.     <meta name="generator"
  4.    content="HTML Tidy for HTML5 (experimental) for Windows https://github.com/w3c/tidy-html5/tree/c63cc39" />
  5.     <style>
  6. #json{
  7. /*  display:none;*/
  8. }
  9. #resultTxt {
  10.   margin: 10px;
  11.   padding: 15px;
  12.   border: 1px solid blue;
  13.   width: 79%;
  14.   min-height: 30px;
  15.   background: lightblue;
  16. }
  17. #contoh{width:80%;min-height:100px;}
  18. table.example {
  19.   background: lightblue;
  20. }
  21.  
  22. table.example tr:nth-child(odd) {
  23.   background: #f6fce6;
  24. }
  25.  
  26. table.example tr:nth-child(even) {
  27.   background: #dee7fc;
  28. }
  29. </style>
  30.     <title></title>
  31.   </head>
  32.   <body>
  33.     <form>
  34.     <textarea id='contoh' onkeyup='convert(2)' onchange='convert(2)'></textarea>
  35.     <br/><textarea id='json' name='json'>dalam coding.. ini tidak akan terlihat</textarea>
  36.       <input type='button' value='tes' onclick='convert()' /><input type='button' value='submit' onclick='submitThis()' />
  37.     </form>
  38.     <div>Preview:
  39.       <p id='resultTxt'>ss</p>
  40.     </div>
  41.     <script>
  42.     function submitThis(){
  43.         alert('anggap disubmit! data yang diproses ada di json!!');
  44.     }
  45.     function convert(time=0){
  46.     timeOut=time * 1000;
  47.     target=document.getElementById('contoh');
  48.     txt=target.value.trim();
  49.     console.log(txt);
  50.     rows=   txt.split("\n");
  51.     console.log(rows);
  52.     result='<table class="example">';
  53.     data={}
  54.     for(i=0;i<rows.length;i++){
  55.         row=rows[i];
  56.         ar=row.split("\t");
  57.         result = result + '<tr><td>';
  58.         result = result + ar.join("</td>\n<td>");
  59.         key = ar[0];
  60.         data[key]=ar;
  61.         result = result + '</td></tr>'
  62.     }
  63.     result=result+'</table>';
  64.     console.log(result);
  65.     document.getElementById('resultTxt').innerHTML ='sedang di proses';
  66.     setTimeout(function(){
  67.         document.getElementById('resultTxt').innerHTML = result;
  68.         document.getElementById('json').innerHTML = JSON.stringify(data);
  69. //      target.style.display='none';
  70.         console.log(target);
  71.  
  72.     },timeOut);
  73. }</script>
  74.   </body>
  75. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement