Javascript 从下拉列表中获取值到textarea JS
我有一个下拉列表,可以从表单生成器中获取字段,在下拉列表的正下方有一个文本区域。我希望将下拉列表中的值放入当前光标位置所在的文本区域。这与检测下拉列表中的变化有关 任何帮助都将不胜感激,因为我一直在努力解决这个问题Javascript 从下拉列表中获取值到textarea JS,javascript,c#,asp.net-mvc,backbone.js,bootstrapping,Javascript,C#,Asp.net Mvc,Backbone.js,Bootstrapping,我有一个下拉列表,可以从表单生成器中获取字段,在下拉列表的正下方有一个文本区域。我希望将下拉列表中的值放入当前光标位置所在的文本区域。这与检测下拉列表中的变化有关 任何帮助都将不胜感激,因为我一直在努力解决这个问题 define(["jquery", "underscore", "backbone", "text!templates/app/tab-nav-actions.html", "text!templates/app/textbox.html", "text!templates/
define(["jquery", "underscore", "backbone", "text!templates/app/tab-nav-actions.html", "text!templates/app/textbox.html", "text!templates/app/textarea.html", "views/select", "helper/pubsub"],
function($, _, Backbone, _tabNavTemplate, _textboxTemplate, _textareaTemplate,Select, PubSub) {
return Backbone.View.extend({
tagName: "div",
className: "tab-pane col-xs-12 col-sm-12 col-md-12 col-lg-12",
initialize: function() {
this.id = this.options.id.toLowerCase().replace(/\W/g, '');
this.id = this.id;
this.tabNavTemplate = _.template(_tabNavTemplate);
this.textboxTemplate = _.template(_textboxTemplate);
this.textareaTemplate = _.template(_textareaTemplate);
this.select = new Select({
id: this.id + (new Date().getTime() - 2),
collection: this.collection,
className: "col-xs-6 col-sm-6 col-md-5 col-lg-4 col-md-offset-1 col-lg-offset-1"
});
this.drop = new Select({
id: this.id + (new Date().getTime() - 2),
collection: this.collection,
className: "col-xs-6 col-sm-6 col-md-5 col-lg-4 col-md-offset-1 col-lg-offset-1"
});
this.render();
},
render: function() {
$("#actionstabs").append(this.tabNavTemplate({
title: this.options.title,
id: this.id
}));
this.$el.attr("id", this.id);
this.$el.append("<div class='actionsheadingrow col-xs-12 col-sm-12 col-md-12 col-lg-12'><h2>To</h2></div>");
this.$el.append(this.select.render().el);
this.$el.append("<div class='col-xs-12 col-sm-12 col-md-12 col-lg-12'><h2>Subject</h2></div>");
this.$el.append(this.textboxTemplate({
subjectclasses: "col-xs-6 col-sm-6 col-md-5 col-lg-4 col-md-offset-1 col-lg-offset-1",
id: this.id + "subject"
}));
this.$el.append("<div class='col-xs-12 col-sm-12 col-md-12 col-lg-12'><h3>Message</h3></div>");
this.$el.append(this.textareaTemplate({
bodyclasses: "col-xs-6 col-sm-6 col-md-8 col-lg-4 col-md-offset-1 col-lg-offset-1",
id: this.id + "Message"
}));
this.$el.append(this.drop.render().el);
this.$el.appendTo("#actionscontent");
this.delegateEvents();
}
});
drop.onchange = function(){
textareaTemplate.value = textareaTemplate.value + this.append; //to appened
//mytextbox.innerHTML = this.value;
}
});
我建议看一个级联下拉列表。从中,您可以提取更改事件并获取下拉列表的值。然后您需要做的就是设置文本区域的文本。像这样的