【问题标题】:im having one textarea and button in html. when i click the button whatever content inside the textarea will be downloaded in the form of .DOCX file我在 html 中有一个 textarea 和一个按钮。当我单击按钮时,文本区域内的任何内容都将以 .DOCX 文件的形式下载
【发布时间】:2018-01-20 20:40:22
【问题描述】:

这是我的场景

我有一个文本区域和三个按钮。一个按钮被命名为PDF 另一个被命名为 doc,另一个被命名为 excel。如果我输入任何 文本区域内的数据,我必须下载这些内容 三种文件格式。我不知道该怎么做。请帮我 解决这个问题

提前致谢

 <html>
 <head>
 <title>file</title>
 </head>
 <script 
 src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js">
 </script>
 <body id="target">
 <p> reason:</p>
 <div>
 <textarea id="content" rows="4" cols="70"></textarea>
 </div>
 <div id="editor"></div>
 <button  id="cmd">as pdf</button>
 <button  id="cmd1">as doc</button>
 <button  id="cmd2">as excel</button>
  </body>
  </html>

【问题讨论】:

    标签: javascript java jquery html


    【解决方案1】:

    您可以制作一个表单,并将这三个按钮视为提交。然后您可以通过 post 值检查哪个“提交”被准确点击(例如,在 php 中)

    if($_POST['cmd']) { do_something(); }
    if($_POST['cmd1']) { do_something_else(); }
    if($_POST['cmd2']) { do_something_another(); }
    

    然后从该表单获取 textarea 值作为输入。

    【讨论】:

    • 但是如何将其下载为 .doc 文件?
    猜你喜欢
    • 2021-10-05
    • 2013-07-18
    • 2021-05-11
    • 1970-01-01
    • 2016-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多