I'm making a report where it would show the data of the incidents happened in a month. There are 4 options per incident that happened. What do I need to do to get all the 4 selected values in every incident and export the whole table including the selected values to excel?
I tried the php form handling but I can't make it work also javascrip. but I can't make the values selected show.
// PHP
for ($i=0; $i < count($dates); $i++) {
echo "
<tr>
<td>$tripdate[$i]</td>
<td contenteditable='true'></td>
<td>$cicuitNumber[$i]</td>
<td>$triptime[$i]</td>
<td>$dates[$i]</td>
<td>$dates1[$i]</td>
<td>$dates2[$i]</td>
<td contenteditable='true'> </td>
////////////// OPTION#1 ///////////////////
<td>
<div class='form-group'>
<select class='form-control' id='InterruptionCause' name='InterruptionCause' >
<option value ='0' selected>0</option>
<option value='001'>001</option>
<option value='002'>002</option>
<option value='003'>003</option>
<option value='004'>004</option>
</select>
</div>
</td>
////////////// OPTION#2 ///////////////////
<td>
<div class='form-group'>
<select class='form-control' id='InterruptionWeather'>
<option value='101'>101</option>
<option value='102'>102</option>
<option value='103'>103</option>
</select>
</div>
</td>
///////////// OPTION#3 //////////////
<td>
<div class='form-group'>
<select class='form-control' id='InterruptionDevice'>
<option value='201'>201</option>
<option value='202'>202</option>
<option value='203'>203</option>
</select>
</div>
</td>
///////////// OPTION#4 /////////////
<td>
<div class='form-group'>
<select class='form-control' id='InterruptionEquipment' >
<optionvalue='301'>301</option>
<option value='302'>302</option>
<option value='303'>303</option>
<option value='304'>304</option>
<option value='305'>305</option>
</select>
</div>
</td>
</tr>
";
}
// Exporting to excel
function fnExcelReport() {
var tab_text = '<html xmlns:x="urn:schemas-microsoft-com:office:excel">';
tab_text = tab_text + '<head><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>';
tab_text = tab_text + '<x:WorksheetOptions><x:Panes></x:Panes></x:WorksheetOptions></x:ExcelWorksheet>';
tab_text = tab_text + '</x:ExcelWorksheets></x:ExcelWorkbook></xml></head><body>';
tab_text = tab_text + "<table border='1px'>";
tab_text = tab_text + $('#myTable').html();
getSelectValue();
tab_text = tab_text + '</table></body></html>';
var data_type = 'data:application/vnd.ms-excel';
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
if (window.navigator.msSaveBlob) {
var blob = new Blob([tab_text], {
type: "application/csv;charset=utf-8;"
});
navigator.msSaveBlob(blob, '<?php echo $date." Interruption Report";?>.xls');
// location.reload();
}
} else {
$('#export').attr('href', data_type + ', ' + encodeURIComponent(tab_text));
$('#export').attr('download', '<?php echo $date." Interruption Report";?>.xls');
// location.reload();
}
}
I expect the output of 4 selected values of every incident to show when I export it to excel. but when I did, only the other data reflected and there are no selected values in the dropdown shows.