Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 5th, 2006, 05:48 AM
Registered User
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Square Brackets in Form Names

Hi there Java ppl,

I'm quite an experienced PHP developer, but very new to Java. And iv got a prb thats been a big headache:

I'm using square brackets to name my (PHP-generated) form elements so that they form an array. ie.
<SELECT name='info[$x]'><option>...etc

Now I want to write some Java whereby you can click a button and the select boxes change their selected value. But when I name elements with the square brackets I can't refer to them!

I've tried:

document.forms[0].info[selectBox].selectedIndex = 0; as well as:
document.forms[0].elements[0].selectedIndex = 0;

Nothing works! Please help me, I cant sleep when iv got a coding problem!

Old July 11th, 2006, 02:29 PM
ewm ewm is offline
Registered User
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

The trick is to refer to the form element using a different script syntax:


Now get some sleep


Similar Threads
Thread Thread Starter Forum Replies Last Post
Names of Form Controls sektor Excel VBA 0 September 4th, 2008 02:41 AM
unique attribute names for form elements fishmonkey XSLT 3 March 16th, 2008 07:46 PM
drawing a square wave nyc9 Visual C++ 1 December 31st, 2006 09:16 AM
Getting form element names in a loop crapanz Javascript 5 January 30th, 2006 12:45 AM
Square root Ashleek007 C++ Programming 3 December 12th, 2004 04:21 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.