Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何以html格式将数据存储到浏览器缓存目录?_Html_Forms_Jscript - Fatal编程技术网

如何以html格式将数据存储到浏览器缓存目录?

如何以html格式将数据存储到浏览器缓存目录?,html,forms,jscript,Html,Forms,Jscript,该项目: 我需要将表单中的数据发布到{div id=result}{/div}中,然后存储到本地缓存目录。有人能帮我写这段代码吗?我想做的是制作一个本地站点,以便加载到Android Hibrid应用程序中 表格: <body> <div class="w3-container"> <div class="w3-card-4" style="width:100%"> <header class="w3-container w3-light-grey"&

该项目:

我需要将表单中的数据发布到{div id=result}{/div}中,然后存储到本地缓存目录。有人能帮我写这段代码吗?我想做的是制作一个本地站点,以便加载到Android Hibrid应用程序中

表格:

<body>

<div class="w3-container">
<div class="w3-card-4" style="width:100%">
<header class="w3-container w3-light-grey">
<h2><Div id="nameBox"></Div></h2>
</header>
<div class="w3-container">
<h2><div id="result"></div></h2>
</div>
</div>
</div>

<div class="w3-container">
<div class="row">
<div class="col-md-8">
<h3>Adicionar um Envelope e Saldo</h3>

<form name="contact-form" 
method="post" id="contact-form">
<div class="form-group">
<label for="inputName">Envelope</label>
<input type="text" 
class="form-control" id="cardName" name="cardName" placeholder="Envelope" 
required>
</div>

<div class="form-group">
<label for="inputValue">Valor</label>
<input type="number" class="form-control" id="Value" name="Value" 
placeholder="Valor" required>
</div>

<div class="form-group">
<label for="inputDescription">Descrição</label>
<input type="text" class="form-control" id="Description" 
name="Description" 
placeholder="Descrição" required>
</div>

<button onclick="store()" class="btn btn-primary" name="submit" 
value="Submit" 
id="submit_form">Adicionar</button>

</form> 
</div>
</div>
</div>

</body>
</html>
我还需要在单击按钮时创建新div

java代码

<script>

function store(){
    if (typeof(Storage) !== "undefined") {  
        var inputName = document.getElementById("cardName");
        sessionStorage.setItem("cardName", inputName.value);

        var inputValue = document.getElementById("Value");
        sessionStorage.setItem("Value", inputValue.value);

        var inputDescription = document.getElementById("Description");
        sessionStorage.setItem("Description", inputDescription.value);

        document.getElementById("result1").innerHTML = sessionStorage.getItem("cardName");
        document.getElementById("result2").innerHTML = sessionStorage.getItem("Value");
        document.getElementById("result3").innerHTML = sessionStorage.getItem("Description");

        } else {
        document.getElementById("result").innerHTML = "Ops! Alguma coisa deu errado...";
    }
}
我明白了! 刚插入类型=按钮上的按钮

<button onclick="store()" **type="button"** class="btn btn-primary" 
name="submit" value="Submit" 
id="submit_form">Adicionar</button>

目录还是MySQL?你说你想写一个web服务,但是你用什么服务器来做呢?那么这不是一个代码编写服务,我们帮助编写代码,发布问题的用户应该进行适当的研究和自己的努力,而你显然没有,提供一个。如果你做不到,请带着它回来。如果有不清楚的地方,请重读。