Hi all,
How to generate textboxes dynamically on click of a button using struts components alone...
Pls help me with this issue....
if u find any PDF regarding Dynamic forms in Struts send me the path .
Thanks in advance
Surekha Veeramani![]()
Hi all,
How to generate textboxes dynamically on click of a button using struts components alone...
Pls help me with this issue....
if u find any PDF regarding Dynamic forms in Struts send me the path .
Thanks in advance
Surekha Veeramani![]()
Hi surekha,
Hope this could help you,
Pls find the attachment for your perusal
IF u want to enhance this, place a javascript for loop in the generateRow function and iterate and generate the textboxes on One click of the add button
Thank You
30-01-07, 01:27 PM #3Junior Member![]()
![]()
- Join Date
- Jan 2007
- Posts
- 5
- Rep Power
- 7
Re: Struts Framework
That was a good question...i need it without using java script is that possible to do
30-01-07, 03:14 PM #4Member![]()
![]()
![]()
![]()
![]()
![]()
![]()
- Join Date
- Jul 2006
- Posts
- 57
- Rep Power
- 12
Re: Struts Framework
I have completed the text box cretaion using java scripts but I was also asked to do without using java scriptsLast edited by surekhav; 06-02-07 at 11:19 AM.
30-01-07, 06:18 PM #5Re: Struts Framework
generateTextBoxes.jsp
< html >
< body >
< form name="textBoxesForm" method="post" action="textBoxesAction.do" >
< table >
< TR >
< TD >Quantity:< /TD >
< TD >< input type=text name="textbox" >< /TD >
< TD >SomeCode:< /TD > < TD >< input typ="txt" name="somecode">< /TD >
< /TR >
< TR >
< TD >< input type="submit" value="Add Buttons" / >< /TD >
< /TR >
< % if (request.getAttribute("noOfTextBoxes")!=null) {
int noOfBoxes = Integer.parseInt((String)request.getAttribute("noOfTextBoxes"));
for(int i=0;i < noOfBoxes; i++){ % >
< input type="txt' name="txtbox < %i% >" >
< % }
} % >
< table >
< body >
< /html >
//In the Action Class
set a value,in the request attribute specifying the no of textboxes u want
Make it as a string
request.setAttribute("noOfTextBoxes","10");
and again redirect to the the same page in struts-config.xml
< action path="/someAction" forward ="jsps/generateTextBoxes.jsp" >
< /action >
This shows you how to generate text boxes
By default when u load this page, there wont be any text boxes, after you click on the submit button , the request attribute "noOfTextBoxes" will be set to a value in the action class or a servlet and since you are redirecting the page again to the same page, then the request attribute will be having a value of 10 and thus generates the text boxes.
Pls let me know your questions
Note: I gave wrong intentionally in input tag of text box, otherwise it is displaying the text box in the post
Thank You,Last edited by t_mohan; 07-02-07 at 03:24 PM.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
tips & tricks windows
By yathish in forum Amazing TIPS & TRICKSReplies: 4Last Post: 11-01-09, 11:34 PMhelp
By Unregistered in forum ORACLE , SQL SERVER , SYBASE & OthersReplies: 2Last Post: 15-08-07, 02:21 PMMySql and PHP ebook
By sand_softnet in forum PERL, PYTHON, PHP & MY SQLReplies: 10Last Post: 31-01-07, 01:59 PMWindows XP : Fast fixes for slow computers
By sk_kireeti in forum NETWORK ADMINISTRATION , HARDWARE & TROUBLESHOOTINGReplies: 2Last Post: 19-11-06, 02:36 AMtips & tricks windows-2
By yathish in forum Amazing TIPS & TRICKSReplies: 2Last Post: 05-09-06, 06:50 PMTags for this Thread
Content Relevant URLs by vBSEO 3.5.1 PL1