每次选择 HTML 中的 <option> 标签时,如何更改 jspdf pdf 文件?

How do i make the jspdf pdf file changes everytime an <option> tag in HTML is choosen?

对不起,我的英语很糟糕,而且我是一个绝对的初学者,但我该如何完成这项工作

    <html>
  <title>form</title>
  <script type = "text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"></script> 
<script type= "text/javascript">
   

   function genPDF() {
    var doc = new jsPDF();

doc.text(45,45, "burgerking");
doc.addImage(imgData, 'JPEG',0.25, 0.25, 210, 300);
doc.addPage();
doc.addImage(imgData, 'JPEG',0.25, 0.25, 210, 300);
doc.addPage();
doc.addImage(imgData, 'JPEG',0.25, 0.25, 210, 300);
if (document.getElementById("ice-cream").value == "choco") {
    doc.text(50,65, "please work")

}
else {
    doc.text(50,65, "knowing that you'll learn stuff when");
    doc.text(50,69, "failing miserably, you're filled with xd");

}


doc.save('form.pdf')
}
       

</script>


 <div>
<label>what kind of ice cream do you want?```<br>
<select id="ice-cream" onchange="genPDF()">```<br>
   <option value="vani"> Vanilla </option>```<br>
   <option value="choco"> Chocolate </option>```<br>
</select><br><br>
 </div>

显然,该代码无法正常工作,所以任何人都可以帮忙 ;-;

这是工作代码。你检查过imgData了吗?那就是破坏密码。我刚刚评论了它的工作原理。还要检查 Pdf 的最后一页。

<html>
  <title>form</title>
  <script type = "text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"></script> 
<script type= "text/javascript">
   

   function genPDF() {
    var doc = new jsPDF();

doc.text(45,45, "burgerking");
//doc.addImage(imgData, 'JPEG',0.25, 0.25, 210, 300);
doc.addPage();
//doc.addImage(imgData, 'JPEG',0.25, 0.25, 210, 300);
doc.addPage();
//doc.addImage(imgData, 'JPEG',0.25, 0.25, 210, 300);
alert(document.getElementById("ice-cream").value)
if (document.getElementById("ice-cream").value == "choco") {
    alert('ere');
    doc.text(50,65, "please work")
}
else {
    doc.text(50,65, "knowing that you'll learn stuff when");
    doc.text(50,69, "failing miserably, you're filled with xd");
}
doc.save('form.pdf')
}
       

</script>


 <div>
<label>what kind of ice cream do you want?```<br>
<select id="ice-cream" onchange="genPDF()">```<br>
   <option value="vani"> Vanilla </option>```<br>
   <option value="choco"> Chocolate </option>```<br>
</select><br><br>
 </div>