[英]Page keeps refreshing when its crucial for the data to be shown on the page
所以我得到了这个东西,但它似乎显示了我需要的东西(例如,你需要接受法规)但之后页面立即刷新,但我需要数据只保留在页面上。 如何处理? 太多的代码限制真的很烦人,所以我必须在这里写这样的东西来避免它——删除不必要的东西会花费太多时间,所以我希望我不会被禁止或……哈哈。
<html>
<head>
<meta charset="utf-8">
<title> Usługi informatyczne </title>
<link rel="stylesheet" type="text/css" href="styl.css">
<body>
<div id="kontener">
<div id="logo">
<img src="logo.png" alt="logo">
</div>
<div id="menu">
<a href="index.html">O nas</a>
<a href="uslugi.html">Usługi</a>
<a href="kontakt.html">Kontakt</a>
</div>
<div id="baner">
<img src="animacjak.gif" alt="">
</div>
<div id="blok_glowny">
<hr />
<h2>Kontakt</h2>
<form id="formularz" action="">
<table>
<tr>
<td>Imię:</td> <td><input type="text" id="imie"><br></td>
</tr>
<tr>
<td>Nazwisko:</td> <td><input type="text" id="nazwisko"></td>
</tr>
<tr>
<td>E-mail:</td> <td><input type="text" id="email"></td>
</tr>
<tr>
<td>Usługa</td> <td><textarea name="usluga" id="usluga"></textarea></td>
</tr>
<tr>
<td></td> <td><input type="checkbox" id="regulamin" value="regulamin">Zapoznałam/em się z regulaminem</td>
</tr>
<tr>
<td></td> <td><input type="reset" value="Resetuj"><input type="button" onclick="przeslij()" value="Prześlij"></td>
</tr>
</table>
</form>
<div id="pokaz"> </div>
<script type="text/javascript">
function przeslij(){
var imie=document.getElementById("imie").value;
var nazwisko=document.getElementById("nazwisko").value;
var usluga=document.getElementById("usluga").value;
var regulamin=document.getElementById("regulamin").checked;
document.getElementById("formularz").submit();
if(regulamin==true){
document.getElementById("pokaz").innerHTML=imie.toUpperCase()+" "+nazwisko.toUpperCase()+"<br />"+
"Treść twojej sprawy:"+usluga+"<br />"+"Na podany adres e-mail zostanie wysłana oferta";
}
else{
document.getElementById("pokaz").innerHTML="Musisz zapoznać się z regulaminem";
document.getElementById("pokaz").style.color="red";
}
}
</script>
<hr />
</div>
<div id="stopka">
<p>Autor strony: 00301011337</p>
</div>
</div>
</body>
</head>
</html>
您的 function 缺少括号
function przeslij() { ... }
要使重置按钮起作用,只需将其类型更改为“重置”
<input type="reset" value="Resetuj">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.