我有个表单如下:
<form name="myform">
Show:<input name="tt" type="text" size=40><br>
<input type="submit" value="Submit">
</form>如何实现按了这个SUBMIT按钮,那个textbox里显示文字比如"message hello"?还有,是否有办法,本身TEXTBOX和BUTTON是隐藏的,旁边有个连接,按了连接才TEXTBOX出现?谢谢啦
<form name="myform">
Show:<input name="tt" type="text" size=40><br>
<input type="submit" value="Submit">
</form>如何实现按了这个SUBMIT按钮,那个textbox里显示文字比如"message hello"?还有,是否有办法,本身TEXTBOX和BUTTON是隐藏的,旁边有个连接,按了连接才TEXTBOX出现?谢谢啦
本身TEXTBOX和BUTTON是隐藏的,旁边有个连接,按了连接才TEXTBOX出现
这个问题很简单啊。。就是设置他们的style属性。。display为none/block
Show:<input name="tt" id="tt" type="text" size=40><br>
<input type="submit" value="Submit">
<script type='javascript/text'>
function showMessage(){
document.getElementById("tt").value='你要显示的信息';
}
document.getElementById("tt").onclick=showMessage;
</script>
</form>
<a href="javascript:void(0);" onclick="document.getElementById('tt').type = 'text';">Show:</a>
<input id="tt" name="tt" type="hidden" size="40" />
<br />
<input type="submit" value="Submit" id="btn" />
</form>
<script type="text/javascript">
document.getElementById('btn').onclick = function() {
document.getElementById('tt').value = 'message hello';
return false;
}
</script>
表单中的submit按钮按下后如果不返回false,表单就提交了。这样做有什么意义呢?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<script type="text/javascript">
function Test()
{
document.getElementById("tt").value="message hello";
}
</script>
</head>
<body>
<form name="myform" onsubmit="Test();" action="http://www.baidu.com" target="_blank">
Show:<input name="tt" id="tt" type="text" size=40><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<script type="text/javascript">
function Test()
{
document.getElementById("tt").value="message hello";
}
function show()
{
document.getElementById("tt").style.display="";
document.getElementById("btn").style.display="";
}
</script>
</head>
<body>
<form name="myform" onsubmit="Test();" action="http://www.baidu.com" target="_blank">
Show:<input name="tt" id="tt" type="text" size=40 style="display:none"><br>
<input type="submit" value="Submit" style="display:none" id="btn">
<a href="#" onclick="show()">显示</a>
</form>
</body>
</html>