我希望有一个HTML格式的框,例如:
特别的是,我需要仅使用HTML(没有PHP或需要服务器或特定安装的特定语言)来执行此操作。
这样做的原因是它用于HTML页面,它将从USB密钥而不是网站打开,并且必须由任何非专业人员使用。因此,如果我是对的,则不需要Web服务器配置或安装,例如PHP需要什么。
答案 0 :(得分:1)
考虑不使用表单,只使用Javascript函数。
由于安全原因,我不确定这是不是可能,但它可能是一个解决方案......
function redirect() {
var input = document.getElementById("stuff");
window.location = input.value;
}
<span>NOM:</span>
<input type="text" id="stuff"></input>
<br>
<input type="button" onclick="redirect()" value="Submit"></input>
答案 1 :(得分:0)
由于Anders Anderson的回答,我设法做了我需要的事情。这是有兴趣做类似事情的人的代码。首先,对于Javascript
function redirect() {
var answergiven = document.getElementById("answergiven");
var realanswer = document.getElementById("realanswer");
var nextpage = document.getElementById("nextpage");
if(answergiven.value.toLowerCase() == realanswer.value.toLowerCase()){
window.location = nextpage.value;
}
else{
alert('Wrong answer, please try again.');
}
return false; // prevent further bubbling of event
}
对于HTML部分,有两个隐藏变量确定真正的答案,下一页要去,以及答案的文本字段
<form name="myform" onSubmit="return redirect()">
<span>Réponse:</span>
<input type="text" id="answergiven" />
<input name="tosubmit" type="submit" value="Submit" />
<input type="hidden" id="realanswer" value="theanswer" />
<input type="hidden" id="nextpage" value="thenextpage.html" />
</form>