View Full Version : Textarea length script with images

11-09-2006, 09:43 AM
Some peoples on my web are like to post me large emailes via my e-mail form.

I was thinking that it would be great to add posting indicator to my mailing form.

I found a lot of word counters here - Form Effects (http://www.dynamicdrive.com/dynamicindex16/) - but showing how much words user posted means nothing.

Then I think out another indicator...

First of all, I will make some photos or use smileys to indicate my mood about amount of words.

For example:
50 words - image displaying ":) OK, keep going"
100 words - image displaying ":D GREAT! You do not need to post more"
150 words - image displaying ":eek: OOHMY... Are you really sure you need to write so much words?"
200 words - image displaying ":confused: HMM... I think I`m not gooing to read such a large mail"

According to words amount entered into textfield, the image (or image and textfield) will be changed.

Please, help me to create such Form Effect

11-09-2006, 09:49 AM
<textarea name="message" .... onChange="checklen(this)"></textarea>
<img name="smiley" ...>

The function should be SOMETHING like this... The logic is right but the exact code is not:

function checklen(field) {
if (strlen(field) < 50) { smiley.src = "happy.gif"; }
else if (...<100) {..."laugh.gif"; }
else if....

The better option might be to use a <span> and change the contents thereof to relate, if you want to change more than just the image.
I'm not quite sure how to do this.

But... the above should give you an idea of what to do.

11-09-2006, 01:48 PM
Thank you for reply!

Speaking the truth, I`m not very in programming, but I`m trying! :)