|
|
 |
Re: FN-FORUM: Javascript error
date posted 21st September 2007 11:38
I may be old-fashioned on this, but I normally use
document.forms['queryform']. etc. etc. instead of document.queryforms.
That may fix it.
Me.
Quoting ADH WebCreations [EMAIL REMOVED]
>
> Hello,
>
> This will be a easy for you guys.
>
> I have a textbox in a form which only allows 1000 characters and I've
> seen on a forum I installed on the site a character countdown and I want
> to use that for my textbox.
>
> The javascript code is:
>
>
> var noalert =3D true, gralert =3D false, rdalert =3D false, clalert =3D fa=
lse;
> var prevsec =3D 5
> var prevtxt
> var cntsec =3D 0
>
> function tick() {
> cntsec++
> calcCharLeft()
> timerID =3D setTimeout("tick()",1000)
> }
>
> var autoprev =3D false
> var topicfirst =3D true;
>
> function enabPrev() {
> =09if ( autoprev =3D=3D false ) {
> =09=09autoprev =3D true
> =09=09topicfirst =3D true
> =09=09document.queryform.Summary.focus();
> =09=09autoPreview();
> =09}
> =09else {
> =09=09autoprev =3D false;
> =09=09ubbstr =3D '';
> =09=09document.queryform.Summary.focus();
> =09}
> =09calcCharLeft()
> }
> function calcCharLeft() {
> clipped =3D false
> maxLength =3D 1000
> if (document.queryform.Summary.value.length > maxLength) {
> =09document.queryform.Summary.value =3D
> document.queryform.Summary.value.substring(0,maxLength)
> =09charleft =3D 0
> =09clipped =3D true
> } else {
> =09charleft =3D maxLength - document.queryform.Summary.value.length
> }
> prevsec++
> if(autoprev && prevsec > 5 && prevtxt !=3D
> document.queryform.Summary.value) {
> =09autoPreview()
> =09prevtxt =3D document.queryform.Summary.value
> }
> }
>
>
>
> and on the textbox I have:
>
> onclick=3D"javascript:calcCharLeft(this);"
> onkeyup=3D"javascript:calcCharLeft(this);"
> onchange=3D"javascript:calcCharLeft(this);">
> Left
>
> I understand bits of javascript but it keeps coming up with an error
> saying:
>
> if (document.queryform.Summary.value.length > maxLength) { is null or
> not an object"
>
> Can anyone help?
>
> Kind regards
>
> Ashley Harvey
> ADH WebCreations
> 07967 791738
> www.adhwebcreations.co.uk
>
>
>
> --
> Freelancers, contractors earn more with Prosperity4
> Call 0870 870 4414 or visit www.prosperity4.com
> and benefit from Inland Revenue approved expenses today.
>
> To advertise here: http://www.freelancers.net/advertising.html
>
> |
 |
|