如何将html表单的内容保存为.html页面 [英] how to save the content of html form as .html page
问题描述
我正在尝试创建一个在线拖放表单,并想知道如何使用HTML扩展程序或作为模板将丢弃的内容与各自的ID一起保存。
HTML:
< html>
< head>
< meta http-equiv =content-typecontent =text / html; charset = UTF-8>
< link rel =stylesheettype =text / csshref =/ css / result-light.css>
< / head>
< body>
< div id =divcontainer>
//在div1和div3中m随机删除字段
< div id =div1ondrop =drop(event,this.id)ondragover =allowDrop(event)><< ; / DIV>
< div id =div3ondrop =drop(event,this.id)ondragover =allowDrop(event)>< / div>
< / div>
< / body>
< / html>
删除所有字段后,我想将表单保存为HTML页面。任何人都可以建议我怎么做。
您应该阅读divcontainer中的html
like
$('#divcontainer')。html()
$ b $ $ $ $ $ $ $> document.getElementById( 'divcontainer')。innerHTML
然后你应该追加这个内容来形成标签,如
var saveForm ='< form>'+ $('#divcontainer')。html()+'< / form>';
现在,saveForm将为表单提供html。你已经将这个保存为包含html和body标签的页面,并且你需要像php或.net这样的后端技术来保存文件。
i am trying creating an online drag and drop form and would like to know how to save the dropped contents along with their respective id's with HTML extension or as a template. HTML:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type='text/javascript' src='//code.jquery.com/jquery-1.9.1.js'></script>
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
</head>
<body>
<div id="divcontainer">
//in div1 and div3 m dropping the fields randomly
<div id="div1" ondrop="drop(event,this.id)" ondragover="allowDrop(event)"></div>
<div id="div3" ondrop="drop(event,this.id)" ondragover="allowDrop(event)"></div>
</div>
</body>
</html>
after dropping all the fields, i want to save the form as an HTML page. Can anyone suggest me how to do so.
You should read the html inside divcontainer
like
$('#divcontainer').html()
or
document.getElementById('divcontainer').innerHTML
Then you should append this content to form tag like
var saveForm = '<form>'+$('#divcontainer').html()+'</form>';
Now saveForm will have html for the form. You have save this as a page with wrapping html and body tags and you need back end technology like php or .net to save file.
这篇关于如何将html表单的内容保存为.html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!