我有个表单如下:
<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出现?谢谢啦

解决方案 »

  1.   

    这样的话点击按钮会触发form的action。。
    本身TEXTBOX和BUTTON是隐藏的,旁边有个连接,按了连接才TEXTBOX出现
    这个问题很简单啊。。就是设置他们的style属性。。display为none/block
      

  2.   

    <form name="myform">
        
      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>
      

  3.   

    <form name="myform">
      <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,表单就提交了。这样做有什么意义呢?
      

  4.   

    第一个:
    <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>
      

  5.   

    第二个:<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";
     }
     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>
      

  6.   

    谢谢LS各位我发现按了按钮后就提交了啊,会打开新页面如何不打开新页面呢?不用SUBMIT按钮,换成个连接也行先谢谢了啊