General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 30th, 2008, 04:24 AM
angela53 angela53 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 4 angela53 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 12 sec
Reputation Power: 0
Count number of letters

Hi all,

I need help with a form. I want to count the number of letters typed into a text box and then pass that number to another form element. Anyone know if this is possible and how to do it.
With thanks
Angela

Reply With Quote
  #2  
Old June 30th, 2008, 08:41 AM
dragonbite dragonbite is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Location: Connecticut, USA
Posts: 41 dragonbite User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 16 m 9 sec
Reputation Power: 11
Depends on the language, but would (VB.NET), but would this work?
Code:
x = len(textbox1.text)
or
x=TextBox1.TextLength
Or is the queston more along the line of getting the count "on the fly" (as they type)? I just did a quick thing in Visual Studio and this would take the lenght of what I'm typing and display it in a label on the form.
Code:
    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Label1.Text = TextBox1.TextLength.ToString
    End Sub
If you are running ASP or some other web form then I am not sure how to do that, but I think it would require using Javascript since for server-sided activity (such as counting each letter typed in) requires posting back to the server.

Hope any of this helps.

Reply With Quote
  #3  
Old June 30th, 2008, 10:24 AM
angela53 angela53 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 4 angela53 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 12 sec
Reputation Power: 0
Thanks for that, but over my head.

I was thinking more of a javascript or php

What I want is for the customer to fill in a text field with a name and then have the number of letters in the name passed to a new form element.

It's for a shopping cart (The number of letters in the name is what is being charged for per letter)
Thanks
Angela

Reply With Quote
  #4  
Old June 30th, 2008, 12:24 PM
Bobidybob's Avatar
Bobidybob Bobidybob is offline
Contributing Abuser
Click here for more information
 
Join Date: Apr 2007
Location: Starkville, MS
Posts: 336 Bobidybob User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 Days 15 h 51 m 40 sec
Reputation Power: 12
Send a message via AIM to Bobidybob
in php, to get the length of a string:

PHP Code:
 strlen($str); 

where $str is the variable you saved the textbox string into

in javascript you just add a .length to get the length of a string. so for the following:

Code:
var txt="Hello World!"; 

txt.length would return a 12

----------------------------------------------------
so in php, your html form would be something like this:

Code:
<form method = "post" action = "form.php">
<input type = "text" name = "variable1" /><br />
<input type = "submit" value = "Submit" />


and in form.php (the page you're passing it to), you can extract and use the variable any way you want. in this example, i'm just printing it out.

PHP Code:
<?php
            extract
$_POST );
            print( 
"$variable1);
?>
__________________

Last edited by Bobidybob : June 30th, 2008 at 12:34 PM.

Reply With Quote
  #5  
Old June 30th, 2008, 12:34 PM
dragonbite dragonbite is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Location: Connecticut, USA
Posts: 41 dragonbite User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 16 m 9 sec
Reputation Power: 11
Quote:
Originally Posted by angela53
Thanks for that, but over my head.

I was thinking more of a javascript or php

What I want is for the customer to fill in a text field with a name and then have the number of letters in the name passed to a new form element.

It's for a shopping cart (The number of letters in the name is what is being charged for per letter)
Thanks
Angela

Does the counting happen while they are typing it or do they hit a "submit" or "recalculate total" button and then it calculates the number of letters?

Reply With Quote
  #6  
Old June 30th, 2008, 05:39 PM
angela53 angela53 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 4 angela53 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 12 sec
Reputation Power: 0
While they are typing it. as in validating a form. So the number of letters they have typed into the box is passed as a quantity.
In my form, at the moment, the customer types a name and then is to select the number of letters from a drop down box, but most just skip that part.

Reply With Quote
  #7  
Old June 30th, 2008, 05:41 PM
angela53 angela53 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 4 angela53 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 12 sec
Reputation Power: 0
validation

sorry I posted this twice

Last edited by angela53 : June 30th, 2008 at 05:44 PM. Reason: double post

Reply With Quote
  #8  
Old July 2nd, 2008, 09:58 AM
Bobidybob's Avatar
Bobidybob Bobidybob is offline
Contributing Abuser
Click here for more information
 
Join Date: Apr 2007
Location: Starkville, MS
Posts: 336 Bobidybob User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 Days 15 h 51 m 40 sec
Reputation Power: 12
Send a message via AIM to Bobidybob
here's a little tool that does live validation. it's free and has examples.

http://www.livevalidation.com/

Reply With Quote
  #9  
Old February 7th, 2011, 04:34 AM
eulogypros eulogypros is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2011
Location: US
Posts: 3 eulogypros User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 4 sec
Reputation Power: 0
You could use those eulogy examples at any time

If you have been handed the daunting job of writing a eulogy for your cherished one's funeral service, you will likely want to read an eulogy sample or two. Actually, the faster you can get your hands on to review, the better ready you will be for establishing the suitable tone and theme for your personal cherished one's eulogy. It is never easy to summarize an entire life and legacy in one single, sincere speech. But by reviewing an eulogy sample - pinpointing what truly speaks to you and ruling out what may not be as fitting inside your specific conditions - you will be sure to get the right tone. Keep in mind the eulogy to be as unique because the dearly departed. Just simply because some situation is included in an instance you have study does not always mean that it should be incorporated in the funeral speech that you're composing. Give some thought as towards the type of service you are holding for your cherished one. Think about your cherished one's character, and the emotions of your fellow mourners. If the recently deceased was known for his pervasive sense of humor, maybe a joke could be fitting. Otherwise, you might wish to get some other's opinions on what aspects to get from any particularly touching instance you've read.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Count number of letters


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap