使用按钮和javascript显示/隐藏表单 [英] Show/hide forms using buttons and javascript
本文介绍了使用按钮和javascript显示/隐藏表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用按钮显示表单,并在用户按另一个按钮时隐藏它,因为另一个按钮显示另一个表单。我用选择框做了类似的事情,但我无法弄清楚如何做到这一点。
解决方案
使用下面的代码片段隐藏按钮点击的表单。
document.getElementById(your form id)。style.display =none;
以下代码显示它
document.getElementById(your form id)。style.display =block;
或者您可以同时使用相同的功能
函数asd(a)
{
if(a == 1)
document.getElementById(asd)。style.display = 无;
else
document.getElementById(asd)。style.display =block;
$ / code $ / pre
< form id =asd> form< / form>
< button onclick =asd(1)>隐藏< / button>
< button onclick =asd(2)>显示< /按钮>
I need to show a form using a button, and hide it when the user presses another button, because the other button shows another form. I did a similar thing with select box, but I can't figure out how to do this.
解决方案 use the following code fragment to hide form on button click.
document.getElementById("your form id").style.display="none";
and following code to display it
document.getElementById("your form id").style.display="block";
or you can use the same function for both purposes
function asd(a)
{
if(a==1)
document.getElementById("asd").style.display="none";
else
document.getElementById("asd").style.display="block";
}
and the html
<form id="asd">form </form>
<button onclick="asd(1)">Hide</button>
<button onclick="asd(2)">Show</button>
这篇关于使用按钮和javascript显示/隐藏表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文