• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Getting values of dynamically created text fields

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In a web application of mine, I am having a form and in that form, textfields(<input type "text"> are created dynamically based on parameters passed from another program. The user fills in values. The common thing among these textfields are they have their names starting with "tfDyn". After the user fills in values, and on submission of the form a servlet is called that is supposed to do some processing based upon the submitted form. My question is,in the servlet, is it possible to get the names and values of the textfields, those that were generated at runtime... if yes, how..or else is there any other way to achieve the same..

Thanks

Vijai
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Perhaps this is what you are looking for where paramName should be the the name of your text field in the HTML form. Remember to give the same name to all the textFields what ever the number you have dynamically created.
 
Vijaishanker bala
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Aslam
But if I give all the text fields the same name, I wont be able to sort out which value belongs to which text field, since they are unique values which need to processed uniquely,depending on the name of the textfield. I am trying my luck right now, with
request.getParameterMap() on this one.

Vijai
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are generating the parameter names, why not remember them in the session as they are being written to the form?
 
aslam parveez
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Probably helps...
 
Vijaishanker bala
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Aslam,

the code snippet you provided worked like a charm. Have used it in my application.

Thanks

Vijai
 
Let nothing stop you! Not even this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic