3

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>
user1342164
  • 1,404
  • 13
  • 40
  • 77

1 Answers1

4

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>
Karl Anderson
  • 34,026
  • 12
  • 64
  • 79