把如下代码加入%26lt;body%26gt;区域中
%26lt;SCRIPT LANGUAGE=%26quot;JavaScript%26quot;%26gt;
%26lt;!-- Begin
oldvalue1=0;
oldvalue2=0;
oldvalue3=0;
function textCounterMulti(cntnum,toplimit,field1,field2,field3) {
var gtposition = new Array()
var ltposition = new Array()
var tagtext = new Array()
tagtext[0]=0;
var total_length=(field1.value.length+field2.value.length+field3.value.length);
var actual_length=(field1.value.length+field2.value.length+field3.value.length);
var totalstring=(field1.value+field2.value+field3.value);
// find how many less than signs we have
lt='1';
opencount = 0;
opos = totalstring.indexOf(%26quot;%26lt;%26quot;);
while ( opos != -1 ) {
opencount++;
ltposition[lt]=totalstring.indexOf(%26quot;%26lt;%26quot;,opos);
opos = totalstring.indexOf(%26quot;%26lt;%26quot;,opos+1);
total_length=ltposition[lt];
lt++
}
gt='1'
closecount = 0;
cpos = totalstring.indexOf(%26quot;%26gt;%26quot;);
while ( cpos != -1 ) {
closecount++;
gtposition[gt]=totalstring.indexOf(%26quot;%26gt;%26quot;,cpos);
cpos = totalstring.indexOf(%26quot;%26gt;%26quot;,cpos+1);
gt++
}
for(tt=1;tt%26lt;=opencount;tt++){
//alert(gtposition[tt]+%26quot; is the position of closer # %26quot;+tt);
if (closecount == opencount){
//alert(tt);
tagtext[tt]=((gtposition[tt]+1)-(ltposition[tt]))
//alert(tagtext[tt])
if(tt%26gt;1){
tagtext[tt]=(tagtext[tt-1]+tagtext[tt])
//alert(tagtext[tt])
document.headermaker.textintags.value=tagtext[tt];
}
}
}
total_length=(actual_length-tagtext[opencount]);
if((closecount=='0')%26amp;(opencount!='0')){
total_length=actual_length-(actual_length-ltposition[opencount]);
}
if((closecount%26lt;opencount)%26amp;(closecount!='0')){
insideopencount=opencount-1;
//alert(tagtext[closecount]+%26quot;n%26quot;+tagtext[opencount])
total_length=1//actual_length-tagtext[insideopencount]((actual_length-ltposition[opencount]));
}
if((closecount=='0')%26amp;(opencount=='0')){
total_length=actual_length;
}
//alert(actual_length-(actual_length-ltposition[opencount]))
var maxvalue1 = ((toplimit)-((field2.value.length)+(field3.value.length))+(tagtext[opencount]));
var maxvalue2 = ((toplimit)-((field1.value.length)+(field3.value.length))+(tagtext[opencount]));
var maxvalue3 = ((toplimit)-((field1.value.length)+(field2.value.length))+(tagtext[opencount]));
//alert(field3.value.length+%26quot;, %26quot;+toplimit)
/*
if ((field1.value.length %26gt; maxvalue1)%26amp;(toplimit!='0')%26amp;(oldvalue1 != field1.value.length)){
alert(field1.value.length+%26quot; is the length, the last gt sign is at %26quot;+field1.value.lastIndexOf(%26quot;%26gt;%26quot;)+%26quot; and the character at the end is %26quot;+field1.value.charAt(field1.value.length-1);)
field1.value.value = field1.value.substring(0, maxvalue1);
oldvalue1=field1.value.length;
oldvalue2=field2.value.length;
oldvalue3=field3.value.length;
}else
if ((field2.value.length %26gt; maxvalue2)%26amp;(toplimit!='0')%26amp;(oldvalue2 != field2.value.length)){
field2.value.value = field2.value.substring(0, maxvalue2);
oldvalue1=field1.value.length;
oldvalue2=field2.value.length;
oldvalue3=field3.value.length;
}else
if ((field3.value.length %26gt; maxvalue3)%26amp;(toplimit!='0')%26amp;(oldvalue3 != field3.value.length)){
field3.value.value = field3.value.substring(0, maxvalue3);
oldvalue1=field1.value.length;
oldvalue2=field2.value.length;
oldvalue3=field3.value.length;
// otherwise, update 'characters left' counter
}else{*/
if ((field1.value.length %26gt; maxvalue1)%26amp;(toplimit!='0')%26amp;(oldvalue1 != field1.value.length)){
//alert(field1.value.length+%26quot; is the length, the last gt sign is at %26quot;+field1.value.lastIndexOf(%26quot;%26gt;%26quot;)+%26quot; and the character at the end is %26quot;+field1.value.charAt(field1.value.length-1))
if(field1.value.charAt(field1.value.length-1)!=%26quot;%26gt;%26quot;){
field1.value = field1.value.substring(0, maxvalue1);
//alert(%26quot;you have exceeded the limit of %26quot;+toplimit+%26quot; characters for this item!nYour text has been trimmed to fit, make changes and verify all paragraphs!%26quot;)
}else if(field1.value.charAt(field1.value.length-1)==%26quot;%26gt;%26quot;){
lasttaggroup=field1.value.substring(field1.value.lastIndexOf(%26quot;%26lt;%26quot;), (field1.value.lastIndexOf(%26quot;%26gt;%26quot;)+1))
//alert(lasttaggroup)
field1.value = (field1.value.substring(0,ltposition[opencount]-1)+lasttaggroup);
//alert(%26quot;you have exceeded the limit of %26quot;+toplimit+%26quot; characters for this item!nYour text has been trimmed to fit, make changes and verify all paragraphs!%26quot;)
}
oldvalue1=field1.value.length;
oldvalue2=field2.value.length;
oldvalue3=field3.value.length;
} else
if ((field2.value.length %26gt; maxvalue2)%26amp;(toplimit!='0')%26amp;(oldvalue2 != field2.value.length)){
if(field2.value.charAt(field2.value.length-1)!=%26quot;%26gt;%26quot;){
field2.value = field2.value.substring(0, maxvalue2);
//alert(%26quot;you have exceeded the limit of %26quot;+toplimit+%26quot; characters for this item!nYour text has been trimmed to fit, make changes and verify all paragraphs!%26quot;)
}else if(field2.value.charAt(field2.value.length-1)==%26quot;%26gt;%26quot;){
lasttaggroup=field2.value.substring(field2.value.lastIndexOf(%26quot;%26lt;%26quot;), (field2.value.lastIndexOf(%26quot;%26gt;%26quot;)+1))
//alert(lasttaggroup)
field2.value = (field2.value.substring(0, ltposition[opencount]-1)+lasttaggroup);
}
oldvalue1=field1.value.length;
oldvalue2=field2.value.length;
oldvalue3=field3.value.length;
} else
if ((field3.value.length %26gt; maxvalue3)%26amp;(toplimit!='0')%26amp;(oldvalue3 != field3.value.length)){
if(field3.value.charAt(field3.value.length-1)!=%26quot;%26gt;%26quot;){
field3.value = field3.value.substring(0, maxvalue3);
//alert(%26quot;you have exceeded the limit of %26quot;+toplimit+%26quot; characters for this item!nYour text has been trimmed to fit, make changes and verify all paragraphs!%26quot;)
}else if(field3.value.charAt(field3.value.length-1)==%26quot;%26gt;%26quot;){
lasttaggroup=field3.value.substring(field3.value.lastIndexOf(%26quot;%26lt;%26quot;), (field3.value.lastIndexOf(%26quot;%26gt;%26quot;)+1))
//alert(lasttaggroup)
field3.value = (field3.value.substring(0, ltposition[opencount]-1)+lasttaggroup);
}
oldvalue1=field1.value.length;
oldvalue2=field2.value.length;
oldvalue3=field3.value.length;
} else if ((field1.value.length %26lt;= maxvalue1)%26amp;(field2.value.length %26lt;= maxvalue2)%26amp;(field3.value.length %26lt;= maxvalue3)){
oldvalue1=field1.value.length;
oldvalue2=field2.value.length;
oldvalue3=field3.value.length;
cntnum.value = toplimit - total_length;
}
}
// End --%26gt;
%26lt;/script%26gt;
%26lt;form name='headermaker'%26gt;
%26lt;input type='hidden' name='textintags'%26gt;
%26lt;TEXTAREA NAME=%26quot;textarea1%26quot; ROWS=%26quot;4%26quot; COLS=%26quot;48%26quot;
onKeyDown=%26quot;textCounterMulti(document.headermaker.remLen1,100,document.headermaker.textarea1,document.headermaker.textarea2,document.headermaker.textarea3)%26quot;
onKeyUp=%26quot;textCounterMulti(document.headermaker.remLen1,100,document.headermaker.textarea1,document.headermaker.textarea2,document.headermaker.textarea3)%26quot;%26gt;

