[英]Can I set an html text field value to a variable, so it saves the previously entered content?
[英]How to convert html content to ms word after I entered value in input text?
我輸入值后,我試圖將html內容轉換為Microsoft word(.doc),我已經完成了如何將html內容轉換為ms字,但是當我在輸入文本中輸入值時,輸入的文本沒有顯示在ms字上。 它只顯示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>
這是我將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>
你實際上是在這里混合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");
}
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.