最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to display a value in a variable in textbox? - Stack Overflow

programmeradmin1浏览0评论

I am new to script. I need to display the value in textbox i have created the textbox inside the tag of my html file. The processed value is in "var a" variable. How can i set the value in textbox

I am new to script. I need to display the value in textbox i have created the textbox inside the tag of my html file. The processed value is in "var a" variable. How can i set the value in textbox

Share Improve this question edited Sep 14, 2011 at 12:30 JB Nizet 693k93 gold badges1.3k silver badges1.3k bronze badges asked Sep 14, 2011 at 12:25 arnparnp 3,2088 gold badges28 silver badges44 bronze badges 1
  • Some code would help. And Java != JavaScript. – JB Nizet Commented Sep 14, 2011 at 12:30
Add a ment  | 

1 Answer 1

Reset to default 2

With JavaScript something like

var a = 'bla bla bla';
var textBox = document.getElementById("TextBoxID");
textBox.value = a;

Maybe you want to wrap it in some function (pass the text instead)

function addText(text) {
    code above;
}

Dont forget to bind it with some kind of event (example onClick)

发布评论

评论列表(0)

  1. 暂无评论