使用JavaScript隐藏表单 [英] hide form using JavaScript
本文介绍了使用JavaScript隐藏表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
JavaScript:
Javascript:
function next(a)
{
if(a==1)
{
document.getElementById("form1").style.display="none";
}
}
HTML:
<form onsubmit="next(1)" action="add.php" method="post" id="form1">
<center>Add New Survey</center>
<p> </p>
<p align="left"> Title: </p>
<textarea name="title" cols="2" class="inputs" id="title"></textarea>
<p align="left"> Discription: (Optional) </p>
<textarea name="dis" cols="2" class="inputs" id="dis"></textarea>
<p align="left"> Number of questions: </p>
<input type="Submit" value="Next" class="button" name="b1"/>
</p>
</form>
这是我的代码.当我提交表单时,它隐藏了几秒钟,然后又出现了.我想隐藏它,直到按下另一个按钮,在另一个按钮处调用另一个javascript函数来显示表单.请帮我.我是Java语言的新手.
Here is my code. When I submit the form, it concealed the form for a few seconds and then again it showed up. I want to hide it until another button is pressed where another javascript function is called to show the form. Please help me. I am new to Javascript.
推荐答案
您需要使用return false
<form onsubmit="return next(1)" action="add.php" method="post" id="form1">
然后
function next(a)
{
if(a==1){
document.getElementById("form1").style.display="none";
return false;
}
}
更新:显示表单
<input type="Submit" value="Show" class="button"
onclick="return showForm()" name="show"/>
function showForm()
{
document.getElementById("form1").style.display="block";
return false;
}
这篇关于使用JavaScript隐藏表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文