0

I have a button in my form, which generates PDF files and saves in the local machine; now after saving them in local machien by clicking the button I want to see the files in the browser for download too(which more than one files) ;

My attempted code is as following:

<form name="frm1" id="frm1" method="post" enctype="multipart/form-data">
         .
         .
         .
  <button type="submit" name="btnCreatePDF_8" class="btn btn-primary" onclick= "newDoc();"> Export to PDF </button>
</form>


<script>
       function newDoc()
       {
           window.open("http://localhost/MyProject/1234_1_8.pdf")
       }
</script>

It creates the PDFs but I cannot get my javascript function (newDoc()) work!

Your help is appreciated! Also if you need more clarification, please let me know which part I have to provide more clarification.

Thanks

4

2 回答 2

2

不要使用提交按钮。那是您的问题,它正在提交表单并调用该函数。看起来表单提交正在赢得比赛。将其更改为常规按钮。

于 2013-10-09T22:30:27.833 回答
0
  <button name="btnCreatePDF_8" class="btn btn-primary" onclick= "newDoc();"> Export to PDF </button> // remove the type="submit"
于 2013-10-11T01:57:37.477 回答