【发布时间】:2012-04-02 23:32:24
【问题描述】:
如何获取使用 javascript 输入文本字段的值并将其打印到页面?我可以使用警报来查看输入到文本字段中的值,但我无法从函数中获取值以将文本字段打印到页面。 我的代码在这里:http://jsbin.com/olokoq/2
【问题讨论】:
标签: javascript function textfield document.write
如何获取使用 javascript 输入文本字段的值并将其打印到页面?我可以使用警报来查看输入到文本字段中的值,但我无法从函数中获取值以将文本字段打印到页面。 我的代码在这里:http://jsbin.com/olokoq/2
【问题讨论】:
标签: javascript function textfield document.write
inside your html text field call a function on onkeyUp or relevent function
<input type='text' id='id1' onKeyUp='name(this.value);' value='name_value' />
function
<script>
function name(var_value){
document.getElementById("print").value = var_value; // print in a text field
document.getElementById('prnt').innerHtml = var_value; // print in a division
}
</script>
<div id = 'prnt' ></div>
<input type='text' id='print' value='name_value' />
【讨论】:
在SelectSubCat你需要添加以下内容:
document.getElementById('value').innerHTML = txtValue;
然后在你的html中添加:
<span id="value"></span>
这将在您单击按钮后立即将文本输入的值插入到 span 标签中。
【讨论】:
You type:
with document .getElementById('vvaluessss').innerHtml = txtValue;在 selectsubcat 中