简体   繁体   中英

how to save the content of html form as .html page

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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