Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script won't work in firefox...don't know if i'm referencing wrong...

Status
Not open for further replies.

spewn

Programmer
May 7, 2001
1,034
here's my script:

Code:
<script>
function showcharactercount() {
mbody=document.getElementById('body1').value;
mbcount=mbody.length;
document.getElementById('charactercount').innerHTML=mbcount;
 if (mbcount>135) {
 newstr = mbody.slice(0,mbcount-1);
 document.getElementById('body1').innerHTML=newstr;
 showcharactercount();
 }
}
</script>
<textarea class=srch style='width:281;height:52;' id=body1 name=body1 onkeyup=showcharactercount()></textarea><br><br>
<span id=charactercount name=charactercount></span>&nbsp;characters / 100 maximum

this works fine in ie. counts as the person types, if char count goes over 100 then it erases the last char, etc.

however, in firefox, it won't remove last char. everything else works tho. there is no javascript error, either.

no idea. i know that the DOM varies slightly, but don't know if that's the issue.

any ideas?

- g
 
>document.getElementById('body1').innerHTML=newstr;
[tt]document.getElementById('body1').[red]value[/red]=newstr;[/tt]
Besides, that error makes ff recursively call showcharactercount() with no breakout.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top