This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Dynamically setting the name of an input text control in jsp using EL  RSS feed

 
Ranch Hand
Posts: 59
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Can someone please let me know, how to set the name of an input checkbox control dynamically?

Part of the name, will include the product code procured via EL from the session scope attribute.

Let us assume the product code is "8601".

Now I want to have a checkbox with the name 8601_check and want to set this dynamically in my jsp page.

How do I do the above?

Right now, all I have is the following:



I get an error message saying, "Invalid location of text(+") in tag(<input>).
 
Author and ninkuma
Marshal
Posts: 66783
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that everything outside of JSP elements is just template text, so:
 
Bartender
Posts: 1844
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also remember that even if you automatically generate them, they should still be valid names.

8601_check is invalid as it starts with a number rather than a letter or underscore character.

I would suggest "check_8601" instead just to avoid the problems :-)

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66783
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, id values that start with numerics are completely valid. Whether they are a good idea or not is another matter...
 
Ravi Desigan
Ranch Hand
Posts: 59
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for the replies! Appreciate it, my problem is solved now.
 
Stefan Evans
Bartender
Posts: 1844
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Actually, id values that start with numerics are completely valid. Whether they are a good idea or not is another matter...



I guess I'm out of date.
Reference to the HTML 4 spec

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").



It got changed in the HTML5 spec to be more permissive



 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!