Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/464.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 显示其下文本框的值_Javascript_Html_Textbox - Fatal编程技术网

Javascript 显示其下文本框的值

Javascript 显示其下文本框的值,javascript,html,textbox,Javascript,Html,Textbox,我想在它下面的文本框中写下值,我该怎么做?提前谢谢 我写了以下代码: <html> <head> <script language="javascript"> function show (text){ document.write("text"); } </script> </head> <body> <input type=t

我想在它下面的文本框中写下值,我该怎么做?提前谢谢

我写了以下代码:

  <html>
   <head>
    <script language="javascript">
        function show (text){
            document.write("text");
        }
    </script>
</head>
<body>
    <input type=textbox name=textbox value="Insert Name"/>
    <input type=button name=button value="OK" onclick=show(textbox.value)/>
 </body>
  </html>

首先:document.write替换文档内容,使用window.alert等

接下来,考虑其中包含的字段,然后使用Stuff.Fr..TrimeBox。


这是除了其他脚本错误之外的错误:

首先:document.write替换文档内容,使用window.alert或类似的方法

接下来,考虑其中包含的字段,然后使用Stuff.Fr..TrimeBox。


除此之外,还有其他脚本错误:

按如下方式修改html:

<input type=textbox name=textbox value="Insert Name" id="txt" />
<span id="spn"></span>
<input type=button name=button value="OK" onclick="show();" />
function show(){   
  document.getElementById('spn').innerHTML = document.getElementById('txt').value;
}

按如下方式修改html:

<input type=textbox name=textbox value="Insert Name" id="txt" />
<span id="spn"></span>
<input type=button name=button value="OK" onclick="show();" />
function show(){   
  document.getElementById('spn').innerHTML = document.getElementById('txt').value;
}

像这样的方法应该会奏效:


像这样的方法应该会奏效: