Copying Outliers
I am trying to copy two dropdown values and add them to a textbox. I copy one just fine, but can't copy two. I am trying to copy the value "sum" and the value "type" concatenates them and pastes them into a textbox. My code:
function copy() {
var sel = document.getElementById("amount");
var text = sel.options[sel.selectedIndex].value;
var out = document.getElementById("textarea");
out.value += text + "\n";
}
+3
source to share
2 answers
You might want to rename your field with the name "type" as it might be the name of a reserved variable.
Also, I can't see where you are pulling the type value? Try the following:
function copy() {
var sel = document.getElementById("amount");
var textInput = document.getElementById("some_type");
var text = sel.options[sel.selectedIndex].value + textInput.value;
var out = document.getElementById("textarea");
out.value += text + "\n";
}
0
source to share