I found a script for limiting the number of characters input in a textarea. It generally works well.
    <script language="javascript" type="text/javascript">
     function limitText(limitField, limitCount, limitNum) {
        if (limitField.value.length > limitNum) {
    limitField.value = limitField.value.substring(0, limitNum);
        } else {
    limitCount.value = limitNum - limitField.value.length;
     }
     }
  </script>
It is called in the following way:
    onKeyDown="limitText(this.form.areaname,this.form.countdown,150);"
    onKeyUp="limitText(this.form.areaname,this.form.countdown,150);"
On one particular page there can be multiple text areas generated by a repeat loop that are named as
    textarea<?php echo $i; ?>
where $i increments each time.
I have tried various things such as
    $areaname = "areaname" . $i;
and then
    onKeyDown="limitText(this.form.'<?php echo $areaname; ?>',
but cannot get anything to work.
Some help would be much appreciated
