Reputation: 1454
I am populating a textbox using the code below. I would like to make the textbox multiline and every time the code is executed it appends the new text to a new line.
Is there a way to do this using the code below?
<script language="javascript" type="text/javascript">
function getSelected(source, eventArgs) {
var s = $get("<%=NameTextBox.ClientID %>").value;
document.getElementById('<%= NPTextBox.ClientID %>').value = s.substring(s.length - 10);
}
</script>
Upvotes: 3
Views: 7670
Reputation: 34846
Use the newline character ('\n'
), like this:
<script language="javascript" type="text/javascript">
function getSelected(source, eventArgs) {
var s = $get("<%=NameTextBox.ClientID %>").value;
document.getElementById('<%= NPTextBox.ClientID %>').value += s.substring(s.length - 10) + '\n';
}
</script>
Upvotes: 4