javaScript中怎样获取textarea中的值
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN"><HTML><HEAD><TITLE>反转<textare...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> 反转<textarea>中文本的顺序 </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="JavaScript" type="text/javascript">
function splitAndReverseText(textAreaControl){
var textToSplit = textAreaControl.value;
var textArray = textToSplit.split('\n');
var numberOfParts = 0;
numberOfParts = textArray.length;
var reversedString = "";
var indexCount;
for (indexCount = numberOfParts - 1; indexCount >= 0; indexCount--)
{
reversedString = reversedString + textArray[indexCount];
if (indexCount > 0)
{
reversedString = reversedString + "\n";
}
}
textAreaControl.value = reversedString;
}
</script>
</HEAD>
<BODY>
<form name=form1>
<textarea rows="10" cols="40" name="textarea1">
Line 1
Line 2
Line 3
Line 4
</textarea>
<br>
<input type="button" value="Reverse Line Order" name="buttonSplit" onclick="splitAndReverseText(document.form1.textareal)">
</form>
</BODY>
</HTML>
为什么提示错误‘value’为空或不是对象 展开
<HTML>
<HEAD>
<TITLE> 反转<textarea>中文本的顺序 </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="JavaScript" type="text/javascript">
function splitAndReverseText(textAreaControl){
var textToSplit = textAreaControl.value;
var textArray = textToSplit.split('\n');
var numberOfParts = 0;
numberOfParts = textArray.length;
var reversedString = "";
var indexCount;
for (indexCount = numberOfParts - 1; indexCount >= 0; indexCount--)
{
reversedString = reversedString + textArray[indexCount];
if (indexCount > 0)
{
reversedString = reversedString + "\n";
}
}
textAreaControl.value = reversedString;
}
</script>
</HEAD>
<BODY>
<form name=form1>
<textarea rows="10" cols="40" name="textarea1">
Line 1
Line 2
Line 3
Line 4
</textarea>
<br>
<input type="button" value="Reverse Line Order" name="buttonSplit" onclick="splitAndReverseText(document.form1.textareal)">
</form>
</BODY>
</HTML>
为什么提示错误‘value’为空或不是对象 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询