Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to take dynamic values of textboxes to Action class

 
Kartik Tal
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

In my page am having two dropdown on combination of two am getting results of 10 values.
Now I need to display the 10 values with 12 textboxes for each, i.e I will get 120 textboxes totally. Where user will fill the values and submit the page.

How to take these values to action page so that I can update the values in database?

And also like if already there is values for the 12 boxes for each element I need to display them by default.

Please give me a logic for this as am new to this.


Regards,
Kartik
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kartik Talasu wrote:In my page am having two dropdown on combination of two am getting results of 10 values.

Are you saying you have two select boxes each with five values or ... ?
Now I need to display the 10 values with 12 textboxes for each, i.e I will get 120 textboxes totally. Where user will fill the values and submit the page.

How to display 10 values in 12 text boxes?
How to take these values to action page so that I can update the values in database?

Are you working with any framework here?
 
Kartik Tal
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean to say like as am having two dropdown's ID and PLACE on change of both am accessing database and getting some results of 5 or 10 or 20 values or etc......

Suppose i choose ID as 1 and PLACE as India I will get results of 3 people names like A,B and C
so next to A i need to show 12 textboxes, again next to B i need to show 12 textboxes and next to C i need to show 12 textboxes.

And the user will fill some values in these 36 textboxes and submit the page.Now i need to read and save in DB. Am using STRUTS framework.


Regards,
Kartik
 
gaurav kant
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
gaurav kant
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here i am expecting that You have created text boxes as much as You need on page with the help of java script (if not then tell us, i will tell you ).
now put name Your test boxes say You have 3 text boxes
textBox1
textBox2
textBox3

put another hidden text box (say "allTextName") in which You will store comma separated string of name of all text boxes for example "allTextName" value will be "textBox1,textBox2,textBox3"
and while adding or deleting text boxes, update "allTextName".
Now in Your action class, simply get
request.getParameter("allTextName") and tokanize it through ",". at this point You have all the names of textboxes just put in request.getParameter() and fetch the values

Hope it will work
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
jaisai vijay
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use struts indexed properties for the dynamic values.

May the following link will be useful for you
Struts indexed properties
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic