|
Posted by Toby Inkster on 03/06/06 23:16
roN wrote:
> If you go to http://paykiosks.net/new/ad_campaign.htm you can see a form
> with a textarea, on the left side of the textaarea, it displays, how many
> characters are left after you started typing - actually I would like to
> display them from the beginning, but that's another issue (JS) - the last
> number of that number in the input field seems to be cut, why that? How to
> change, that the whole number is displayed?
Here is the table row in question:
<tr>
<td width="22%" align="right" class="text">Comments/
Questions:<br><br> <input name="input1" size="1"
style="border-width:0;background-color:#F7F7F7"
onfocus="if(this.blur)this.blur()" class="text"> chars left </td>
<td valign="top" width="78%"><span class="text">
<textarea name="comments"
onkeyup="count(event)" rows="8" cols="40"
class="flat"></textarea> </span></td>
</tr>
Replace this with:
<tr>
<td width="22%" align="right" class="text">Comments/Questions:<br><br>
<span id="charsleft"></span></td>
<td valign="top" width="78%" class="text"><textarea name="comments"
id="comments" rows="8" cols="40" class="flat"></textarea></td>
</tr>
In your Javascript you have:
function count(e) {
if (!e.which) keyCode = event.keyCode; // ie5+ op5+
else keyCode = e.which; // nn6+
if (document.Formular.comments.value.length<max+1)
document.Formular.input1.value = max-document.Formular.comments.value.length;
else {
document.Formular.comments.value = document.Formular.comments.value.substring(0,max);
document.Formular.input1.value = 0;
}
}
Replace with:
function count(e) {
if (!e.which)
keyCode = event.keyCode; // ie5+ op5+
else
keyCode = e.which; // nn6+
if (document.Formular.comments.value.length<max+1)
{
document.getElementById('charsleft').innerHTML =
(max - document.Formular.comments.value.length)
& ' chars left';
}
else
{
document.Formular.comments.value =
document.Formular.comments.value.substring(0,max);
document.getElementById('charsleft').innerHTML =
'0 chars left';
}
}
document.getElementById('comments').onkeyup = count;
window.onload = count;
Should fix both problems and one more problem that you hadn't spotted.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Navigation:
[Reply to this message]
|