douhuanqiao5290 2017-11-10 05:40
浏览 44

onclick下载按钮要求用户在弹出窗口输入电子邮件ID然后提交他将使用php / ajax / jQuery在他的邮件中获取该pdf?

Here is what I am trying to do

1) Click on download pdf link.(There are list of pdfs) 2) On click Popup will open. Contact form is in the popup. 3) On submit button send mail and auto start download of PDF file. 4) At the same time of starting of download close the popup without redirecting to any page.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Download</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">


  </head>
  <body>

    <div class="container">
        <div class="row">
            <a href="#" class="btn btn-primary" data-toggle="modal" data-target="#download">Download</a>

        <!-- modal for download and contact -->
        <div class="modal fade" id="download" role="dialog" >
        <div class="modal-dialog" >
        <div class="modal-content">


<!-- Your contact form goes here -->
        <form method="post">
        <input type="text" id="name" placeholder="name">
        <input type="text" id="email" placeholder="email">
        <button onclick="send();">send</button>
        </form>


        </div></div></div>
        </div>
    </div>



    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="js/jquery.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>

    <script>
function send(){
var  name = $("input#name").val();
var  email = $("input#email").val();

        $.ajax({
                type: "POST",
                url: "send.php", //your mailing code is place on send.php
                data:'name='+ name'&email='+email,
                success: function(data){
                $('#download').modal('hide');

                //window.open('pdf/fabrilinx-Sodium-Hydrosulphite.pdf');
               window.location.href='pdf/fabrilinx-Sodium-Hydrosulphite.pdf'; //your file location        
                    }
                });
}
</script>
  </body>
</html>

Problem occurs with this code

1) onclick download button, after entering detail pdf wont open in new window 2) How to download same pdf on witch user click, if there are multiple pdf download buttons are there

i have taken this code reference from another post but neither it works nor i have enough points to comments there.

On click open popup with form and then on submit download and close it! How?

Please anyone can help me to get the solution??

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用