HTML form to a Excel spreadsheet (database) -
i not modifying code
<!doctype html> <html> <head> <script type="text/javascript"> function fillhidtable(){ var htqf; //-- hidden field var rf; //-- retrieved field ( var = 1; < 5; i++ ) { rf = "htqf"+i; document.getelementbyid(rf).innerhtml = document.getelementbyid("q"+i+"calc").value; } tabletoexcel('hidtable', 'analysis results'); } var tabletoexcel = (function() { var uri = 'data:application/vnd.ms-excel;base64,' , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/tr/rec-html40"><head><!--[if gte mso 9]><xml><x:excelworkbook><x:excelworksheets><x:excelworksheet><x:name>{worksheet}</x:name><x:worksheetoptions><x:displaygridlines/></x:worksheetoptions></x:excelworksheet></x:excelworksheets></x:excelworkbook></xml><![endif]--></head><body><table>{table}</table></body></html>' , base64 = function(s) { return window.btoa(unescape(encodeuricomponent(s))) } , format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) } return function(table, name) { if (!table.nodetype) table = document.getelementbyid(table) var ctx = {worksheet: name || 'worksheet', table: table.innerhtml} window.location.href = uri + base64(format(template, ctx)) } })() </script> <title>html form data excel</title> <meta name="generator" content="editplus"> <meta name="author" content=""> <meta name="keywords" content=""> <meta name="description" content=""> <style type="text/css" media="screen"> .divcenmid{font-family:arial,sans-serif;font-size:14pt;font-style:normal;font-weight:700;text-align:center;vertical-align:middle;margin:0;} .allbdrcenmid{border:.75pt solid windowtext;color:#000;font-family:arial,sans-serif;font-size:10pt;font-style:normal;font-weight:400;text-align:center;vertical-align:middle;margin:0;} .allbdrcentop{border:.75pt solid windowtext;color:#000;font-family:arial,sans-serif;font-size:10pt;font-style:normal;font-weight:400;text-align:center;vertical-align:top;margin:0;} .allbdrltmid{border:.75pt solid windowtext;color:#000;font-family:arial,sans-serif;font-size:10pt;font-style:normal;font-weight:400;text-align:left;vertical-align:middle;margin:0;} .allbdrlttop{border:.75pt solid windowtext;color:#000;font-family:arial,sans-serif;font-size:10pt;font-style:normal;font-weight:400;text-align:left;vertical-align:top;margin:0;} </style> </head> <body> <table width= "565px" cellspacing="0" cellpadding="0" style="border-spacing:0;" id="qmstable"> <col width="25px"/> <col width="120px"/> <col width="360px"/> <col width="60px"/> <tr> <td class="divcenmid" colspan = "4"> qms assessment</td> </tr> <tr> <td class="allbdrcenmid"> no</td> <td class="allbdrcenmid"> criteria</td> <td class="allbdrltmid"> question</td> <td class="allbdrcenmid"> score</td> </tr> <tr> <td class="allbdrcentop"> q1</td> <td class="allbdrlttop"> quality unit independency</td> <td class="allbdrlttop"> have quality unit?</td> <td class="allbdrcenmid"> <input id="q1calc" type="text" value="" class="nobdrcenmid" style="overflow:hidden; width:93% " name="q1calc"/> </td> </tr> <tr> <td class="allbdrcentop"> q2</td> <td class="allbdrlttop"> apply pics gmp</td> <td class="allbdrlttop"> gmp regulation use?</td> <td class="allbdrcenmid"> <input id="q2calc" type="text" value="" class="nobdrcenmid" style="overflow:hidden; width:93% " name="q2calc"/> </td> </tr> <tr> <td class="allbdrcentop"> q3</td> <td class="allbdrlttop"> deviation or non-conformance</td> <td class="allbdrlttop"> have deviation or non-conformance procedure?</td> <td class="allbdrcenmid"> <input id="q3calc" type="text" value="" class="nobdrcenmid" style="overflow:hidden; width:93% " name="q3calc"/> </td> </tr> <tr> <td class="allbdrcentop"> q4</td> <td class="allbdrlttop"> complaint</td> <td class="allbdrlttop"> have customer complaint procedure?</td> <td class="allbdrcenmid"> <input id="q4calc" type="text" value="" class="nobdrcenmid" style="overflow:hidden; width:93% " name="q4calc"/> </td> </tr> </table> <div id="hidtable" style="display: none"> <table id="testtable"> <caption>supplier risk analysis</caption> <colgroup></colgroup> <colgroup></colgroup> <colgroup></colgroup> <thead> <tr> <th>no.</th> <th>question</th> <th>score</th> </tr> </thead> <tbody> <tr> <td>q1</td> <td>do have quality unit?</td> <td id="htqf1">-</td> </tr> <tr> <td>q2</td> <td>apply pics gmp?</td> <td id="htqf2">-</td> </tr> <tr> <td>q3</td> <td>do have deviation or non-conformance procedure?</td> <td id="htqf3">-</td> </tr> <tr> <td>q4</td> <td>do have customer complaint procedure?</td> <td id="htqf4">-</td> </tr> </tbody> </table> </div> <input type="button" onclick="fillhidtable()" name=patientdatabase value="export data excel"> </body> </html> it makes web based form can play , edit, there way can change last button save excel table cells make more of database , there way can save specific file , have fill in or append data.
you can convert html div excel
var tabletoexcel = (function() { var uri = 'data:application/vnd.ms-excel;base64,' , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/tr/rec-html40"><head><!--[if gte mso 9]><xml><x:excelworkbook><x:excelworksheets><x:excelworksheet><x:name>{worksheet}</x:name><x:worksheetoptions><x:displaygridlines/></x:worksheetoptions></x:excelworksheet></x:excelworksheets></x:excelworkbook></xml><![endif]--></head><body><table>{table}</table></body></html>' , base64 = function(s) { return window.btoa(unescape(encodeuricomponent(s))) } , format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) } return function(table, name) { if (!table.nodetype) table = document.getelementbyid(table) var ctx = {worksheet: name || 'worksheet', table: table.innerhtml} window.location.href = uri + base64(format(template, ctx)) } })()
Comments
Post a Comment