嘿,我想在用户填写输入时显示一个表格。
我所拥有的是:
在<head>
部分:
<script type="text/javascript">
//hide initially
$("table#mytable").hide();
// show function
function showit() {
$("table#mytable").show();
}
</script>
和表格:
<table id="mytable"><tr><td>FOO</td><td>BAR</td></tr></table>
和下面的表格(也许很重要)表格:
<form action="foobar.php">
<input name="example" onselect="showit()" />
<input type="submit" value="Send" />
</form>
我认为 onselect 并不完美,但它应该在我的情况下做这件事。
上面的代码根本没有隐藏表格。我不知道我做错了什么。希望 some1 能找到错误 - 谢谢。
编辑
这是解决方案:
head
:
<script type="text/javascript">
function show(id) {
document.getElementById(id).style.display = 'block';
}
</script>
并在每个要隐藏的元素中添加style="display: none;"
和编辑输入 - 添加onkeyup="show('id')
其中 id 是要隐藏的元素的 id,例如#mytable