Tutorialstream.com Forum Index
 FAQ   Search   Members   Usergroups   Register   Profile   Log in to check your private messages   Log in 

Log in
Username:    Password:      Log me on automatically each visit    
limiting the characters in the textarea area
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Tutorialstream.com Forum Index -> Web Design
View previous topic :: View next topic  
Author Message
pappszaby



Joined: 21 Nov 2005
Posts: 30

PostPosted: Thu Jan 05, 2006 8:29 am    Post subject: limiting the characters in the textarea area Reply with quote

Hi there!
I would like to limit the number of characters in the textarea area.
What to do?
Back to top
View user's profile Send private message
Fed
Site Admin


Joined: 12 Aug 2005
Posts: 176

PostPosted: Thu Jan 05, 2006 11:46 am    Post subject: Reply with quote

here's a javascript that allows you to count the chars into a text area and display your visitor the remaining ones
put these lines between the <head> and </head> tags of your page
Code:
<script language="Javascript" type="text/javascript">
function countAreaChars(areaName,counter,limit)
{
   if (areaName.value.length>limit)
   areaName.value=areaName.value.substring(0,limit);
   else
   counter.value = limit - areaName.value.length;
}
</script>


and these into your page body, obviously you have to adjust them so that they fit your form
Code:
<form name=formName action="myScript.php">
<textarea name=feedback cols=45 rows=6
   onKeyDown="countAreaChars(this.form.feedback,this.form.leftChars,400);"
   onKeyUp="countAreaChars(this.form.feedback,this.form.leftChars,400);">
</textarea>
<input type=text name=leftChars readonly size=3 maxlength=3 value="400"> chars left
</form>


I hope it helps Wink


Last edited by Fed on Mon May 15, 2006 3:59 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pappszaby



Joined: 21 Nov 2005
Posts: 30

PostPosted: Fri Jan 06, 2006 12:03 pm    Post subject: re Reply with quote

Hi Fed! Thanks
It is working properly but now the web mail is not working!
I need this stuff for the same fill out form as it is posted in this forum. I quess you still remember it. It is the next topic in General Help.
Back to top
View user's profile Send private message
Fed
Site Admin


Joined: 12 Aug 2005
Posts: 176

PostPosted: Fri Jan 06, 2006 3:08 pm    Post subject: Reply with quote

well you have to integrate them both
I mean, you don't have to put 2 <form> statements, you need to put only this in your form, where you want the textarea to appear
Code:
<textarea name=feedback cols=45 rows=6
   onKeyDown="countAreaChars(this.form.feedback,this.form.leftChars,400);"
   onKeyUp="countAreaChars(this.form.feedback,this.form.leftChars,400);">
</textarea>
<input type=text name=leftChars readonly size=3 maxlength=3 value="400"> chars left


I hope you understand what I mean (and I hope I understood the reason why it's not working Very Happy)


Last edited by Fed on Mon May 15, 2006 4:00 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pappszaby



Joined: 21 Nov 2005
Posts: 30

PostPosted: Fri Jan 06, 2006 3:53 pm    Post subject: Reply with quote

OK Very Happy
Now is working and I understand the reason!
It is not possible 2 forms in the <body>
Thanks again
You were very helpfull.
I might be back for other questions.
Very Happy
Back to top
View user's profile Send private message
Fed
Site Admin


Joined: 12 Aug 2005
Posts: 176

PostPosted: Fri Jan 06, 2006 4:12 pm    Post subject: Reply with quote

2 forms in the same body are ok, btw they can't be nested Wink
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pappszaby



Joined: 21 Nov 2005
Posts: 30

PostPosted: Fri Jan 06, 2006 4:17 pm    Post subject: Reply with quote

I hope that it is does not bother u that I don't know anything about programing. But I never study programing Embarassed
Back to top
View user's profile Send private message
Fed
Site Admin


Joined: 12 Aug 2005
Posts: 176

PostPosted: Fri Jan 06, 2006 4:23 pm    Post subject: Reply with quote

no worries, you're welcome
don't miss to help the others when someone needs help...this is what forums are supposed to be used for Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pappszaby



Joined: 21 Nov 2005
Posts: 30

PostPosted: Fri Jan 06, 2006 4:25 pm    Post subject: Reply with quote

You are right but while youi were off I get on a hungarian forum and they were rude to me the admin told me that I'm not suposed to ask such things Sad
Your forum is much better Wink
Back to top
View user's profile Send private message
Fed
Site Admin


Joined: 12 Aug 2005
Posts: 176

PostPosted: Fri Jan 06, 2006 4:59 pm    Post subject: Reply with quote

ok because usually you can't go to a forum and say: hello, I need this, can someone make it for me?
you can imagine that this is not the right way, as usually forums are used to clarify little problems while developing something, but until I can and it's a matter of a few lines of code, I like helping the others and I hope you'll do the same when someone needs something you know Wink
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pappszaby



Joined: 21 Nov 2005
Posts: 30

PostPosted: Fri Jan 06, 2006 5:06 pm    Post subject: Reply with quote

Of corese! I understand! I agree but they were a bit rude thats it.
Wink
Back to top
View user's profile Send private message
pappszaby



Joined: 21 Nov 2005
Posts: 30

PostPosted: Mon Jan 09, 2006 7:54 am    Post subject: Reply with quote

Hi Fed!
There is a small problem that I don't know how to correct.
When in the left Chars area the value reaches "0" the mailer.php does not let it go trough because it is set to warn to go back.
For the mailer the "0" value is still an empty value.
So eight er the leftChars area should stop at 1 or the 0 value to be recognize as a value.
Back to top
View user's profile Send private message
Fed
Site Admin


Joined: 12 Aug 2005
Posts: 176

PostPosted: Mon Jan 09, 2006 11:23 am    Post subject: Reply with quote

what's the exact given error/message?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pappszaby



Joined: 21 Nov 2005
Posts: 30

PostPosted: Mon Jan 09, 2006 11:27 am    Post subject: Reply with quote

Because the php looks like this !
<?PHP
$to = "you@xyz.com";
$subject = "Order";
$headers = "Order";
$forward = 0;
$location = "";
$date = date ("l, F jS, Y");
$time = date ("h:i A");
$msg = "Message Date: $date Time: $time.\n\n";
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
foreach ($_POST as $key => $value)
{
if (empty($value))
{
echo "Please go back and fill all the required fields.";
Die();
}
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
else
{
foreach ($_GET as $key => $value)
{
if (empty($value))
{
echo "Please go back and fill all the required fields.";
Die();
}

$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
mail($to, $subject, $msg, $headers);
if ($forward == 1) {
header ("Location:$location");
}
else {
echo "Thank you for your order!";
}

?>
It is imposible to enter a single 0 in any filed because that is equal to an empty field. So if the counter reaches 0 than the filed is equal to an empty filed so basically does not let the mail to go trough
Back to top
View user's profile Send private message
pappszaby



Joined: 21 Nov 2005
Posts: 30

PostPosted: Mon Jan 09, 2006 11:57 am    Post subject: Reply with quote

basically the exact given error massage is the
echo "Please go back and fill all the required fields.";
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Tutorialstream.com Forum Index -> Web Design All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

phpBB SEO URLs V2 - Icons by Mark James

Powered by phpBB © 2001, 2005 phpBB Group