Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Howto point to a textbox?

Reply
Thread Tools

Howto point to a textbox?

 
 
Richard Salin
Guest
Posts: n/a
 
      11-02-2004
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


 
Reply With Quote
 
 
 
 
Michael Winter
Guest
Posts: n/a
 
      11-02-2004
On Wed, 3 Nov 2004 00:43:49 +0200, Richard Salin <(E-Mail Removed)>
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.
 
Reply With Quote
 
 
 
 
Richard Salin
Guest
Posts: n/a
 
      11-02-2004

----- Original Message -----
From: "Michael Winter" <(E-Mail Removed)>
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 <(E-Mail Removed)>
> 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


 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      11-02-2004
On Wed, 3 Nov 2004 01:29:28 +0200, Richard Salin <(E-Mail Removed)>
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.
 
Reply With Quote
 
Richard Salin
Guest
Posts: n/a
 
      11-03-2004

"Michael Winter" <(E-Mail Removed)> kirjoitti
viestissäpsgu2w8lkx13kvk@atlantis...
> On Wed, 3 Nov 2004 01:29:28 +0200, Richard Salin <(E-Mail Removed)>
> 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Share-Point-2010 ,Share-Point -2010 Training , Share-point-2010Hyderabad , Share-point-2010 Institute Saraswati lakki ASP .Net 0 01-06-2012 06:39 AM
Scenario 5: IS-IS routing on Frame Relay Multi-point and Point-to-Point David Sudjiman Cisco 0 06-08-2006 09:11 AM
point to point protocol Gopi VHDL 1 07-13-2004 02:37 PM
simulate point-to-point with 2620's np Cisco 11 03-04-2004 01:44 AM
help, please!! cisco 827H point per point configuration javi Cisco 1 10-16-2003 07:33 AM



Advertisments