输入值后,我正在尝试将html内容转换为Microsoft word(.doc),我已经完成了如何将html内容转化为ms word的操作,但当我在输入文本中输入值时,输入的文本不会显示在ms word上。它只显示html文件的默认内容。
请帮我一下,我的论文急需它,谢谢。这是我的代码:
<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>
这是我将html转换为msword的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>
您实际上是在这里混合php和jquery。。您可以做的是..将表单中的内容发送到文件示例中。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");
}
?>