• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Dynamic adding

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have a page in JSP which has got 2 button Add and Cancel.
and existing 5 text box when I click on Add button it should add the
6th text box below the 5th text box.
Any idea
Regards,
aakash
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What the problem? You can put your textboxes in table one <td> for each textbox when 5 textboxes have "visibility = visible" and the last one has "hidden" until Add button pressed.
For this you don't ever need JSP it's the client side (JavaScript) solution.
Another JS solution may be if you want to create new Textbox for each button pressing.
Here also just client side solution may be used:
you can append to innerHTML of <DIV> or <TD> element
your new textbox html string.


[ February 17, 2003: Message edited by: Alona Samardin ]
 
Ranch Hand
Posts: 250
Python Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Client side scripting may not a suitable solution here as we do not know "how many" text boxes could be added by the user and for this scripting because these text boxes must pre-exist on the HTML.
One of the ways could well be to render this information to the JSP through a query string (MyJsp?howManyMore=4). If the query string value is null we show the original page (with requsite 5 text boxes). As "Add' is clicked we call the same JSP and give it the information as to how many text boxes are to be appended.
I do not know the application of this JSP but a good solution may be - providing a drop-down list of "how-many-more-text-boxes" which the user could select and can add straightaway by clicking on "add". We can always get this information using request.getParameter(..). The resulting page will create the text boxes inside a loop with 5+number_of_text_boxes iterations.
Hope this helps
[ February 17, 2003: Message edited by: Debashish Chakrabarty ]
 
aakash bhatt
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I cannot predefine the no of text box in my html and on clicking ADD button
it should add dynamically one textbox.
I am not allowed to define in a list box the no of textbox to be added.
Is there any other way around.
Regards,
aakash
 
Debashish Chakrabarty
Ranch Hand
Posts: 250
Python Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you go through my post again you will see that apart from suggesting "predefining number of text boxes" I also suggested passing the information through query string. Say you call the page "MyJsp.jsp?howmany=1", get the query string value and increment it by 1 and the next time "Add" is clicked pass the query string as this incremented value and so on. The value passed on as the query string will tell you how many "additional" text boxes you need to generate below your original five. When yr page is called for the very first time this valye will be null.
Hope this helps
 
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic