所以我有这张桌子:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="js2/libs/FileSaver/FileSaver.min.js"> </script>
<script type="text/javascript" src="js2/libs/jsPDF/jspdf.min.js"></script>
<script type="text/javascript" src="js2/libs/jsPDF-AutoTable/jspdf.plugin.autotable.js"></script>
<script type="text/javascript" src="js2/tableExport.min.js"></script>
<?php
include_once("config.php"); //config for database
if(isset($_POST['detail_event_id'])) {
$id_event = $_POST['detail_event_id'];
$query = "SELECT id_user, id_event FROM user_event WHERE id_event = '$id_event'";
$result = mysqli_query($db, $query);
$output = '
<div class="bg-white">
<div class="table-hover margin-top-10px">
<table id="tablePendaftar" class="table table-hover">
<thead>
<tr>
<th>Nama</th>
<th>Tanggal Lahir</th>
<th>E-Mail</th>
<th>Nomor Telepon</th>
<th>Alamat</th>
<th>Deskripsi</th>
</tr>
</thead>
<tbody>
';
if (mysqli_num_rows($result) != 0) {
while ($get = mysqli_fetch_array($result)) {
$id_user = $get['id_user'];
$getuser = "SELECT nama_depan, nama_belakang, tgl_lahir, email, tlp, alamat, deskripsi FROM user WHERE id_user = '$id_user'";
$result2 = mysqli_query($db, $getuser);
while ($getuser = mysqli_fetch_array($result2)) {
$nama_depan = $getuser['nama_depan'];
$nama_belakang = $getuser['nama_belakang'];
$tgl_lahir = date('d F Y', strtotime($getuser['tgl_lahir']));
$email = $getuser['email'];
$tlp = $getuser['tlp'];
$alamat = $getuser['alamat'];
$deskripsi = $getuser['deskripsi'];
$output .= '
<tr>
<td>' . $nama_depan.' '.$nama_belakang . '</td>
<td>' . $tgl_lahir . '</td>
<td>' . $email . '</td>
<td>' . $tlp . '</td>
<td>' . $alamat . '</td>
<td>' . $deskripsi . '</td>
</tr>
';
}
}
}
else{
$output .= '
<tr>
<td>Tidak ada pendaftar</td>
<td>Tidak ada pendaftar</td>
<td>Tidak ada pendaftar</td>
<td>Tidak ada pendaftar</td>
<td>Tidak ada pendaftar</td>
<td>Tidak ada pendaftar</td>
</tr>
';
}
$output .= '</tbody>
</table>
</div>
</div>
';
echo $output;
?>
<a href="#" id="printpdf" class="btn btn-primary">
Download PDF
</a>
<?php
}
?>
<script>
$("#printpdf").click(function(){
$('#tablePendaftar').tableExport({type:'pdf', jspdf: {orientation: 'l',
format: 'a3',
margins: {left:10, right:10, top:20, bottom:20},
autotable: {styles: {fillColor: 'inherit',
textColor: 'inherit'},
tableWidth: 'auto'}
}});
});
</script>
该表出现在html上并显示coorect,但问题是,当我点击表的下载PDF按钮时,控制台显示错误:
TypeError: $(...).tableExport is not a function
并且不会显示下载选项。
我已经按照插件中的教程进行了操作:
https://github.com/hhurz/tableExport.jquery.plugin
你们可以帮我解决这个错误吗?因为我不知道如何解决它,谢谢。