473,407 Members | 2,306 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,407 software developers and data experts.

How do I get a text value from an input element?

If I have this:

<input type="text" onchange="doIt(this);" />

How can I get the value of the textbox in doIt()?

I tried:

function doIt(o){
alert(' it is: " + o.Value);
}

But I get o is undefined.

I am trying to display what the user just typed in and wanted to do it
with the this keyword.

Thank you.
Jun 30 '08 #1
4 1295
jmDesktop wrote:
If I have this:

<input type="text" onchange="doIt(this);" />

How can I get the value of the textbox in doIt()?

I tried:

function doIt(o){
alert(' it is: " + o.Value);
}

But I get o is undefined.
o.Value is `undefined' because ECMAScript implementations are
case-sensitive. o.value should work.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Jun 30 '08 #2
On Mon, 30 Jun 2008 14:02:36 -0700 (PDT), in comp.lang.javascript
jmDesktop <ne***********@gmail.com>
<f3**********************************@59g2000hsb.g ooglegroups.com>
wrote:
>| If I have this:
|
| <input type="text" onchange="doIt(this);" />
|
| How can I get the value of the textbox in doIt()?
|
| I tried:
|
| function doIt(o){
| alert(' it is: " + o.Value);
| }
|
| But I get o is undefined.
|
| I am trying to display what the user just typed in and wanted to do it
| with the this keyword.
|
| Thank you.
The onchange event occurs when a control loses the input focus and its
value has been modified since gaining focus.

The onkeypress event occurs when a key is pressed and released over an
element.
The onkeydown event occurs when a key is pressed down over an element.
The onkeyup event occurs when a key is released over an element.
Jun 30 '08 #3
On Jul 1, 2:02*am, jmDesktop <needin4mat...@gmail.comwrote:
If I have this:

<input type="text" onchange="doIt(this);" />

How can I get the value of the textbox in doIt()?

I tried:

function doIt(o){
* alert(' it is: " + o.Value);

}

But I get o is undefined.

I am trying to display what the user just typed in and wanted to do it
with the this keyword.

Thank you.

The *Value* is not a valid attribute. It is *value*.
Try This.

function doIt(o){
alert(' it is: " + o.value);
}
Jul 1 '08 #4
su********@gmail.com wrote:
On Jul 1, 2:02 am, jmDesktop <needin4mat...@gmail.comwrote:
><input type="text" onchange="doIt(this);" />

How can I get the value of the textbox in doIt()?

I tried:

function doIt(o){
alert(' it is: " + o.Value);

}

But I get o is undefined.

I am trying to display what the user just typed in and wanted to do it
with the this keyword.

The *Value* is not a valid attribute. It is *value*.
Your case suggestion is of course correct, however:

`value' is _not_ the name of an attribute here, but of a *property*. It is
only called an attribute in the HTML source code (which the property
represents, and where case does not matter), and in the specification of
the interface that the DOM host object implements (where case does matter).

Please trim your quotes.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Jul 1 '08 #5

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

Similar topics

4
by: frogman042 | last post by:
My daughter is playing around trying to learn JavaScript and she wrote a small program that prints out a message in increasing and decreasing font size and color changes. She is using document...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin,...
11
by: C.W.Holeman II | last post by:
I what to hide an input element and the following text. I have the selector for the input working and just need to grab the text following it. CSS: form{ display:table; text-align:center; }
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.