jquery - Show value from input in exporting html code to pdf using jspdf -


if post duplicated, please give me references.
because failed finding post appropriate problem.

i have simple form

<div class="form-control" id="input">     <label>name :</label>     <input type="text" name="name" id="name" autocomplete="off" required>     <br><label>class :</label>     <select name="myclass" id="myclass" value="--">         <option>--</option>         <option>class 1</option>         <option>class 2</option>         <option>class 3</option>     </select>     <br><label>date :</label>     <input type="text" name="date" id="date" autocomplete="off" required> </div>  <div>     <button type="button" onclick="printinput()" >submit data</button> </div> 

so, here have make simple code generate form pdf :

<script src="dist/jspdf.min.js"></script> <script src="dist/jspdf.plugin.autotable.js"></script> <script src="lib/jquery.min.js"></script> <script>     function printinput()     {         var doc = new jspdf();         doc.fromhtml($("#input").get(0), 10, 10, {'width': 180});         doc.output('dataurlnewwindow');     } </script> 

but, value input , select not show.

how make value them showing in pdf ?

add div around date , name

<div class="form-control" id="input">     <label><div id="namehide">name :</label>     <input type="text" name="name" id="name" autocomplete="off" required>     <br><label>class :</label>     <select name="myclass" id="myclass" value="--">         <option>--</option>         <option>class 1</option>         <option>class 2</option>         <option>class 3</option>     </select>     <br><label><div id="datehide">date :</label>     <input type="text" name="date" id="date" autocomplete="off" required> </div>  <div>     <button type="button" onclick="printinput()" >submit data</button> </div> 

in script

<script src="dist/jspdf.min.js"></script> <script src="dist/jspdf.plugin.autotable.js"></script> <script src="lib/jquery.min.js"></script> <script>     function printinput()     { document.getelementbyid("namehide").innerhtml="name"+document.getelementbyid("name").value; document.getelementbyid("datehide").innerhtml="date"+document.getelementbyid("date").value;         var doc = new jspdf();         doc.fromhtml($("#input").get(0), 10, 10, {'width': 180});         doc.output('dataurlnewwindow'); document.getelementbyid("namehide").innerhtml="name"; document.getelementbyid("datehide").innerhtml="date";     } </script> 

jspdf not developed yet. need write our own logic print user input. logic appending value html content. renders html , again remove previous append.


Comments