繁体   English   中英

如何将html表单的内容另存为.html页面

[英]how to save the content of html form as .html page

我正在尝试创建在线拖放表单,并且想知道如何保存带有HTML扩展名或模板的拖放内容及其各自的ID。 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>

删除所有字段后,我想将表单另存为HTML页面。 谁能建议我该怎么做。

您应该阅读divcontainer内的html

喜欢

$('#divcontainer').html() 

要么

document.getElementById('divcontainer').innerHTML 

然后,您应该将此内容附加到表单标签中,例如

var saveForm = '<form>'+$('#divcontainer').html()+'</form>';

现在,saveForm将具有用于表单的html。 您已将其保存为带有包装html和body标签的页面,并且需要诸如php或.net的后端技术来保存文件。

暂无
暂无

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

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