473,395 Members | 1,653 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,395 software developers and data experts.

Howto point to a textbox?

Hi
I just wondered how I can refer to the following two
textboxes in this form:

<FORM action="FormWrite.php" method="post" name="submitForm">
<INPUT NAME="inputValues[etunimi]" SIZE=40>
<INPUT NAME="inputValues[sukunimi]" SIZE=40>
<INPUT TYPE="button" onclick="javacscript:sendForm();"
VALUE="Lähetä">
</FORM>
the reason the [] signs are in the name is to get all the textboxes values
in one variable
when using a php script.

- But how can I refer to it with javascript? For example; I tried

alert(document.submitForm.inputValues[etunimi].value);

....but it doesn't work. Can anyone tell me how this is done?
Thanks in advance!

Richard
Jul 23 '05 #1
4 1449
On Wed, 3 Nov 2004 00:43:49 +0200, Richard Salin <No****@ThankYou.com>
wrote:

[snip]
<INPUT NAME="inputValues[etunimi]" SIZE=40>
<INPUT NAME="inputValues[sukunimi]" SIZE=40>
[snip]
- But how can I refer to it with javascript? [...]
Please read the FAQ (<URL:http://jibbering.com/faq/>).
alert(document.submitForm.inputValues[etunimi].value);

...but it doesn't work.


No, that certainly wouldn't. The square bracket notation is used to access
properties. In addition to the relevant article in the Quick Answers
section of the FAQ, you might want to read this article in the FAQ notes:
<URL:http://www.jibbering.com/faq/faq_notes/square_brackets.html>.

[snip]

Hope that helps,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2

----- Original Message -----
From: "Michael Winter" <M.******@blueyonder.co.invalid>
Newsgroups: comp.lang.javascript
Sent: Wednesday, November 03, 2004 1:19 AM
Subject: Re: Howto point to a textbox?

On Wed, 3 Nov 2004 00:43:49 +0200, Richard Salin <No****@ThankYou.com>
wrote:

[snip]
<INPUT NAME="inputValues[etunimi]" SIZE=40>
<INPUT NAME="inputValues[sukunimi]" SIZE=40>


[snip]
- But how can I refer to it with javascript? [...]


Please read the FAQ (<URL:http://jibbering.com/faq/>).
alert(document.submitForm.inputValues[etunimi].value);

...but it doesn't work.


No, that certainly wouldn't. The square bracket notation is used to access
properties. In addition to the relevant article in the Quick Answers
section of the FAQ, you might want to read this article in the FAQ notes:
<URL:http://www.jibbering.com/faq/faq_notes/square_brackets.html>.

[snip]

Hope that helps,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.


The link was very informative, thanks for that, but I haven't figured out
how I could refer directly to the boxes.
I wouldn't want to change their names since the php
script is builded to support those names.
Is it possible to refer to the names with the square brackets? and if so
how?
Thanks again!

Richard
Jul 23 '05 #3
On Wed, 3 Nov 2004 01:29:28 +0200, Richard Salin <No****@ThankYou.com>
wrote:

[snip]
Is it possible to refer to the names with the square brackets? and if so
how?


Yes. :)

var form = document.forms['submitForm'];
var etunimi = form.elements['inputValues[etunimi]'];
var sukunimi = form.elements['inputValues[sukunimi]'];

Good luck,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4

"Michael Winter" <M.******@blueyonder.co.invalid> kirjoitti
viestissä:opsgu2w8lkx13kvk@atlantis...
On Wed, 3 Nov 2004 01:29:28 +0200, Richard Salin <No****@ThankYou.com>
wrote:

[snip]
Is it possible to refer to the names with the square brackets? and if so
how?


Yes. :)

var form = document.forms['submitForm'];
var etunimi = form.elements['inputValues[etunimi]'];
var sukunimi = form.elements['inputValues[sukunimi]'];

Good luck,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.

Jul 23 '05 #5

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

Similar topics

2
by: Simon | last post by:
I've got a webform and many controls on it. I would like to iterate thru the control collection to get all the textboxes control to let me change the text property. Here is my code...for unknown...
5
by: didier Belot | last post by:
Hi! If the subject isn't clear: Modern browsers provide an optional way of remembering user input in textbox: user begin to type, and a list drop down just under the textbox showing matching...
4
by: Vlady | last post by:
Hello. I recently built an ASP.NET "financial" application. I got to the point where I have a HTML template (a contract) which needs to be filled with various data from the database. I put a...
2
by: Dan Sikorsky | last post by:
How do you get the x,y pixel location of a textbox so that you can position the Web Date Control popup nearby the associated textbox that will contain the date selected by the Web Date Control? ...
0
by: Dan Sikorsky | last post by:
I have labels and associated multiline textboxes on a panel that's disabled for the purpose of presenting lengthy readonly comments. Using this method, the textbox scrollbars don't work; the user...
2
by: Dan Sikorsky | last post by:
How can we tell if the value in a FormView EditItemTemplate TextBox has changed from its initial value so that we know if we have to update the corresponding db table column value? -- Thank you...
1
by: Pieter | last post by:
Hi, Is there a way to link the Hidden-property of a Textbox on a Reporting Services Report to it's Value? When the Value is empty (""), then I want the TextBox be Hidden. In case you don't...
5
by: Gohalien | last post by:
I am writing some code, and I wanna "ask" if an object name is not null (aka, the object exist) then do some work, else, do other work... Of course, by doing "If (textbox.name == null)" I get the...
1
by: Radu | last post by:
Hi. I have the following puzzle: I have in the DB a table name "Login_QAByPIN". In it I'll store, for identification purposes, 6 questions with 6 answers for each registered pin. On the...
0
by: dcollier9 | last post by:
Hi ! I need to embed a text box in a footer of a GridView's boundfield column to get data prior to a row insert. The textbox is usable and showing up in the web page source using View
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
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.