/    Sign up×
Community /Pin to ProfileBookmark

reading value of textbox

If there are square brackets [] in name of an item in a form how can you use it in javascript?

Example:

I have a simple form with several text boxes in it in a PHP page.
Textboxes are named like this:

[COLOR=”#FF0000″][/COLOR][B]txtbx[1], txtbx[2],…..[/B]

[COLOR=”#FF0000″][/COLOR][B]<input type=text size=3 name=txtbx[1] value=5>[/B]

[COLOR=”#FF0000″][/COLOR][B]how can I read their value with javascript?[/B]

normally it would be [COLOR=”#FF0000″][/COLOR][B]form.txtbx1.value[/B]
but the square bracket (for array in PHP) is causing problem.

thanks in advance

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@iBeZiDec 11.2012 — You can use [B]form["txtbx[1]"].value[/B] to get the value.
Copy linkTweet thisAlerts:
@JayJavaauthorDec 11.2012 — 1000000 thanks iBeZi.
Copy linkTweet thisAlerts:
@JayJavaauthorDec 12.2012 — Update:

I have tried using this method. Sometimes it works perfectly and sometimes it does not work altough conditions are similar if not identical.

Are there conditions involved in using this?

Can you suggest a link or article to do some reading on this topic.

Thanks in advance
×

Success!

Help @JayJava spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...