0

I am trying to create a front end where user will first input the number of forms they want to create then create those forms and let user fill up those forms with data and then export those form data to an excel file. Here the constraint is I cannot use PHP to do so. The entire thing has to be developed using html and javascript.

I've developed the later portion of the above mentioned task. I have developed a single form, let user to fill up the form and then export the form data using a javascript function to an excel file. But I need here to generate multiple forms first and then export all the data from those forms.

<form name="ADCS" onsubmit= "return exportF()">
                                </select><br>
  <b>Rule name :</b>                    <input id="Predefinedrulename" name="Predefinedrulename" required><br>
  <b>Rating Group Id : </b>             <input id="Monitoringkey" name="Monitoringkey" required><br>
</form>

<table id="table" style="display: none">
  <tr>
    <td id="title_Predefinedrulename">
    <td id="input_Predefinedrulename">
  </tr>
  <tr>
    <td id="title_Monitoringkey">
    <td id="input_Monitoringkey">
  </tr>
</table>

<a style="display: none" id="downloadLink"></a>

<script type="text/javascript">

function exportF() {

//Format the table with form data

  document.getElementById("title_Predefinedrulename").innerHTML = "Predefined rule name";
  document.getElementById("input_Predefinedrulename").innerHTML = document.getElementById("Predefinedrulename").value.replace(/\s/g,'');

  document.getElementById("title_Monitoringkey").innerHTML = "Monitoring key";
  var MK_Value = parseInt(document.getElementById("Monitoringkey").value) + 10000;
  HEX_Vaue = MK_Value.toString(16);
  document.getElementById("input_Monitoringkey").innerHTML = HEX_Vaue.toUpperCase();

 var table = document.getElementById("table");
 var html = table.outerHTML;

  var url = 'data:application/vnd.ms-excel,' + escape(html); // Set your html table into url
  var link = document.getElementById("downloadLink");
  link.setAttribute("href", url);
  link.setAttribute("download", "pmi_data_LIVE.xls"); // Choose the file name
  link.click(); // Download your excel file
  return false;
}
</script>
Yeamin
  • 1
  • 2

0 Answers0