Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-23-2007, 03:22 AM   #1
Registered: Jul 2004
Posts: 34

Rep: Reputation: 15
Question one charater is missed from html form field value

there is a very strong thing to me when i use javascript to get form field value.
the source code is as below:
however, the "content" field always displays only the characters till the second last character from "message" field. For instance, the string typed in "message" field is abcd, then the string in "content" field is abc only.
Did this happen to anyone else? how did you solve this problem?
Thanks for any advices.
Old 04-23-2007, 07:04 AM   #2
Senior Member
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,293

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335

Strange thing yes, this should normally never happen. The only thing I can guess is that you are running that code in an "OnChange" event handler of the field name "message". Is that correct?

If so, I've seen similar things happen. The OnChange event handler is not run until the field loses focus or there is some other event happening. To test this, try to make third input field, bringing it to focus by clicking inside it should then update the "content" field correctly.

As for solutions, I think it's possible to add keyboard event handlers to the field, but it's not easy. A simpler way would be to use an "OnSubmit" handler on the form or something.
Old 04-24-2007, 08:19 AM   #3
Registered: Jul 2004
Posts: 34

Original Poster
Rep: Reputation: 15
Thank you very much for the hints. I finally solved the problem by creating another button to handle submission. Please note the button should be outside the form tag,for anyone encounter the same problem.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Editing Firefox form field history? ylikone Linux - Software 3 03-01-2007 04:47 PM
Exec CGI within a form field newuser455 General 0 09-12-2004 01:50 PM
an html form question matt_w_lambert Programming 3 10-30-2003 11:41 PM
form field in html to have permanent value meluser Programming 3 04-19-2003 02:53 PM
problem with html form meluser Linux - Software 4 03-15-2003 12:28 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:34 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration