+ Reply to Thread
Results 1 to 5 of 5

Thread: How to generate textboxes on the fly with button click using Struts framework?

  1. #1
    Member
    Join Date
    Jul 2006
    Posts
    57
    Rep Power
    12

    How to generate textboxes on the fly with button click using Struts framework?

    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

  2. #2
    Moderator t_mohan's Avatar
    Join Date
    Apr 2006
    Location
    India
    Posts
    578
    Rep Power
    23

    Re: Struts Framework

    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



    Attached Files Attached Files

  3. #3
    Junior 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

  4. #4
    Member
    Join Date
    Jul 2006
    Posts
    57
    Rep Power
    12

    Smile Re: Struts Framework

    I have completed the text box cretaion using java scripts but I was also asked to do without using java scripts
    Last edited by surekhav; 06-02-07 at 11:19 AM.

  5. #5
    Moderator t_mohan's Avatar
    Join Date
    Apr 2006
    Location
    India
    Posts
    578
    Rep Power
    23

    Re: 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.

  6. Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

    Similar Threads

    1. tips & tricks windows
      By yathish in forum Amazing TIPS & TRICKS
      Replies: 4
      Last Post: 11-01-09, 11:34 PM
    2. help
      By Unregistered in forum ORACLE , SQL SERVER , SYBASE & Others
      Replies: 2
      Last Post: 15-08-07, 02:21 PM
    3. MySql and PHP ebook
      By sand_softnet in forum PERL, PYTHON, PHP & MY SQL
      Replies: 10
      Last Post: 31-01-07, 01:59 PM
    4. Windows XP : Fast fixes for slow computers
      By sk_kireeti in forum NETWORK ADMINISTRATION , HARDWARE & TROUBLESHOOTING
      Replies: 2
      Last Post: 19-11-06, 02:36 AM
    5. tips & tricks windows-2
      By yathish in forum Amazing TIPS & TRICKS
      Replies: 2
      Last Post: 05-09-06, 06:50 PM

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts

    Content Relevant URLs by vBSEO 3.5.1 PL1