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>
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>
Share
Improve this question
asked Sep 9, 2013 at 18:13
user1342164user1342164
1,46413 gold badges48 silver badges88 bronze badges
6
-
Have you tried
.value = s.substring(s.length - 10) & vbcrlf);
– Don Thomas Boyle Commented Sep 9, 2013 at 18:24 - It says vbcrlf is undefined? – user1342164 Commented Sep 9, 2013 at 18:38
-
1
Sorry I assumed since it was vb code it would work, my last attempt is for you to try
\n'
like in this post , stackoverflow./questions/5758161/….... hope this helps. So Possibly after yourdocument.GetElement
... dodocument.write("\n");
– Don Thomas Boyle Commented Sep 9, 2013 at 18:44 - I tried that and its throwing errors I added the document.write("\n"); after my last line – user1342164 Commented Sep 9, 2013 at 18:58
- have you tried write('\n'); single quote? also what errors – Don Thomas Boyle Commented Sep 9, 2013 at 18:59
1 Answer
Reset to default 4Use 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>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745108442a4611698.html
评论列表(0条)