Hi all:
This is about PHP trust me!
I have a JavaScript function that limits characters in a <textarea> and displays the number of remaining characters in a text field.
The function is deployed within a SQL/PHP page of dynamically generated items surrounded by <form></form> tags so each item can be submitted to a DataBase.
Here is the function:
//Function to detect and countdown characters in a <textfield>:
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) { // if too long...trim it!
window.alert("The maximum number of characters\nfor this field has been reached.");
field.value = field.value.substring(0, maxlimit);
}
// otherwise, update 'characters left' counter
else {
countfield.value = maxlimit - field.value.length;
}
}
Here are the function calls from within the <textarea>:
<textarea name=\"description\" rows=\"3\" cols=\"20\" wrap=\"virtual\"
onKeyDown=\"textCounter(this.form.description,this.form.remLen,500);\" onKeyUp=\"textCounter(this.form.description,this.form.remLen,500);\">some_value</textarea>
<input type=\"text\" name=\"remLen\" size=\"3\" maxlength=\"3\" value=\"500\" readonly>
When I view the dynamic pages in MSIE 4+ everything works fine for both single and multiple dynamically displayed items.
NS4+ works ok for single items, not for multiple items and generates no error message either, the countdown field simply doesn't countdown.
I've tried naming the form after the unique auto_increment field of the table in my database so that NS4 could recognise individual forms but this does nothing.
Are there any PHP/MySQL developers or JavaScript experts or out there with suggestions of how I may get round this problem??
Any pointers very gratefully received!
Regards:
Russ Michell (APU Webteam)