<textarea name= "TextBox1 " rows= "6 " cols= "35 " id= "TextBox1 "> </textarea>
可能会自动换行,如何使用JavaScript按行读取TextArea的文本?
------解决方案--------------------
<textarea name= "TextBox1 " rows= "6 " cols= "35 " id= "TextBox1 "> </textarea>
<input type= "button " value= "Read " onClick= "testGG() ">
<script language= "javascript ">
function testGG(){
var xxx = document.getElementById( "TextBox1 ");
var yyy = xxx.value.split( "\n ");
for(var i = 0;i < yyy.length;i++){
alert(yyy[i]);
}
}
</script>
------解决方案--------------------
超长换行并不是换行,既然用户没有按回车说明其不想换行
var content = textbox1.value.split( '\n ').join( '<br> ');
newCon.value = content;
<input type=hidden id=newCon runat=server>
.cs
string content = newCon.Value;