473,382 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Form counter & prefilled form field

Hi,

Having an issue with a pretty standard javascript text counter. The
counter works fine when a user physically enters text into a textbox
but shoudl the textbox have a value prefilled then the prefilled value
is not taken into account until the user has entered something in the
textbox.

So basically I have a textbox with "hello" in it and a text counter
which say "10" it is not until the user clicks on the textbox and then
presses key or chnages the text that the counter updates and takes the
"hello" into account, thus chanign the textcounter value to 4 as the
user woudl have pressed the spacebar in this example.

Hope this makes sense. has anyone got any idea on how I can get around
this?
Jul 23 '05 #1
2 4229
Ben Barnes wrote:
Hi,

Having an issue with a pretty standard javascript text counter. The
counter works fine when a user physically enters text into a textbox
but shoudl the textbox have a value prefilled then the prefilled value is not taken into account until the user has entered something in the
textbox.

So basically I have a textbox with "hello" in it and a text counter
which say "10" it is not until the user clicks on the textbox and then presses key or chnages the text that the counter updates and takes the "hello" into account, thus chanign the textcounter value to 4 as the
user woudl have pressed the spacebar in this example.

Hope this makes sense. has anyone got any idea on how I can get around this?


Hi Ben.

Where is the 'prefilled' text coming from? If it's being printed at the
server, the same routine could also initialize the counter. Otherwise,
you can always set an onload handler for the page that explicitly calls
the HTML event handler property involved, e.g.

<input id="foo"....onchange="textcount(this)" />

....can be called:

window.onload = function()
{
document.getElementById('foo').onchange();
}

Jul 23 '05 #2

RobB wrote:
Ben Barnes wrote:
Hi,

Having an issue with a pretty standard javascript text counter. The
counter works fine when a user physically enters text into a textbox but shoudl the textbox have a value prefilled then the prefilled value
is not taken into account until the user has entered something in the textbox.

So basically I have a textbox with "hello" in it and a text counter
which say "10" it is not until the user clicks on the textbox and

then
presses key or chnages the text that the counter updates and takes

the
"hello" into account, thus chanign the textcounter value to 4 as the user woudl have pressed the spacebar in this example.

Hope this makes sense. has anyone got any idea on how I can get

around
this?


Hi Ben.

Where is the 'prefilled' text coming from? If it's being printed at

the server, the same routine could also initialize the counter. Otherwise, you can always set an onload handler for the page that explicitly calls the HTML event handler property involved, e.g.

<input id="foo"....onchange="textcount(this)" />

...can be called:

window.onload = function()
{
document.getElementById('foo').onchange();
}

Hi,

Thanks for taking the time to write.

The text has a value set dynamically from a users input. The problem is
this can change to any length but the counter has a set value which
does not take into accoutn what he user has entered.
I'll give what you have suggested a shot.

Thanks

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Randell D. | last post by:
Folks, I have a form called "ourTestForm". Its a test form - nothing special - it contains five input tags - they are named one, two, three, four and five. The input tags are of type...
1
by: ed_spain | last post by:
Hi Everyone, On an HTML page with 2x different forms, how can I redisplay the same page after a submit, restoring the values from BOTH forms even though only one was submitted? I have an...
0
by: tshad | last post by:
MSN has a toolbar that has a Form Fill function that will try to fill form fields on forms when they come up. The problem is that it causes problems with some forms and functions. I found this...
27
by: Scott | last post by:
I've been trying to come up with a way to ensure user input is coming from the form on my site, and not auto-submitted from elsewhere, and I don't want to use the "enter the code shown in the...
1
by: robing | last post by:
I am having trouble getting data from a text input field element. the element is called amount_$counter with $counter being the row of the table. when i have made an input to the text field and...
2
by: Cerebral Believer | last post by:
Hi folks, Can anyone help me with this form: http://futurebydesign-music.com/_member/club_fbd_reg.php I have followed to coding instructions aas closely as I can, but I am getting errors...
19
by: jimatqsi | last post by:
I'm using Access 2000 (and also 2003 with same result) in a Windows XP Professional environment on a peer-to-peer network. Files in this system are relatively small. There are about 1,200 rows in the...
4
by: Greg Scharlemann | last post by:
I'm trying to setup a dyamic dropdown list that displays a number of text fields based on the selected number in the dropdown. The problem I am running into is capturing the data already entered...
6
by: manifestcomms | last post by:
Hello, I have a form which requires the fields to be valid before the buttons become active. In particular I am having a problem with the email address field. The form is written in PHP using a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.