简体   繁体   English

在输入文本中输入值后,如何将html内容转换为ms字?

[英]How to convert html content to ms word after I entered value in input text?

I am trying to convert html content to Microsoft word (.doc) after I entered value, I had done how to converting html content to ms word but when I entered the value in input text, the entered text is not displaying on the ms word. 我输入值后,我试图将html内容转换为Microsoft word(.doc),我已经完成了如何将html内容转换为ms字,但是当我在输入文本中输入值时,输入的文本没有显示在ms字上。 it only display the default content of the html file. 它只显示html文件的默认内容。

Please help me with this, I need it badly for my thesis thank you. 请帮助我,我的论文非常需要,谢谢你。 here is my code: 这是我的代码:

<form method="post">
    <input type="button" value="Add Row" onclick="addRow('dataTable')">
    <input type="button" value="Delete Row" onclick="deleteRow('dataTable')">
    <table id="dataTable" name="table1" width="350px" border="1">
        <tr>
            <td><p>table value 1</p></td>
            <td><p>table value 2</p></td>
        </tr>
    </table>
    <div align="center">
        <input type="text" name = "text" id = "text" align="center"/></br>
        <input type="button" id = "back" value="Back" class="button" align = "center" />
        <input type="submit" id = "login" name="submit" value="Save" class="button" />
    </div>
</form>

here is my javascript code for converting html to ms word: 这是我将jtml转换为ms字的javascript代码:

<script type="text/javascript">
        $(document).ready(function(){
            $("form").submit(function(){
                <?php
                if(isset($_POST['submit'])){
                header("Content-Type: application/vnd.ms-word"); 
                header("Expires: 0"); 
                header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
                header("content-disposition: attachment;filename=test.doc");
                }
                ?>
            });
        });
</script>

you are actually mixing php with jquery here.. what you can do is.. send the content from the form to a file example. 你实际上是在这里混合php和jquery ..你可以做的是...将表单中的内容发送到文件示例。 info_save.php where you can keep your php code: info_save.php,你可以保存你的PHP代码:

            <?php
            if(isset($_POST['submit'])){
            $name = $_POST['name'];
           // try saving the $name to the file using sme class library
            header("Content-Type: application/vnd.ms-word"); 
            header("Expires: 0"); 
            header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
            header("content-disposition: attachment;filename=test.doc");
            }
            ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM