#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    Ankara,Etlik,TURKEY
    Posts
    0
    Rep Power
    0
    hello,
    i am a newbie in servlets. i am trying to design a student grading system. If a teacher wants to input grades, he will choose a lesson and see the students taking that lesson.My problem starts here. Every student must have an inputbox near him for entering his grade. But number of students are dynamic.
    So, the number of inputboxes must be dynamic. I don't know how to do this.
    For example, i will choose a lesson and all students(for example, 23) taking that lesson will be shown on an HTML page and there will be 23 inputboxes near them. i will eneter grades in this inputboxes and when i submit, all student grades will be recorded to the database at the same time.
    I don't know how to do it dynamically.is it possible to use arrays for inputboxes( like inputbox[1], inputputbox[2],etc.) in HTML?
    Please help me immediately. Source code will be appreciated. And happy new year to all!!!
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    12
    Rep Power
    0
    I guess the easiest way to do it is to use some hidden field to keep a counter for how many student you got, and use a for loop to generate input field:

    assume counter = 23 in your case;

    out.println("<input type='hidden' name='counter' value='"+counter+"'>");
    for (int i=0; i<counter; i++)
    out.println("<input type='text' name='input"+i+"'>");

    Then you can apply the same concept on getParameter:

    int counter = Integer.parseInt(request.getParameter("counter"));

    int counter[] = new int(counter);
    for (int i=0; i<counter; i++)
    counter[i] = Integer.parseInt(req.getParameter("input"+i));

    Hope this would help.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    Ankara,Etlik,TURKEY
    Posts
    0
    Rep Power
    0
    Thank you very much. It was really so important for me. I will use it in my project

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by billylau:
    I guess the easiest way to do it is to use some hidden field to keep a counter for how many student you got, and use a for loop to generate input field:

    assume counter = 23 in your case;

    out.println("<input type='hidden' name='counter' value='"+counter+"'>");
    for (int i=0; i<counter; i++)
    out.println("<input type='text' name='input"+i+"'>");

    Then you can apply the same concept on getParameter:

    int counter = Integer.parseInt(request.getParameter("counter"));

    int counter[] = new int(counter);
    for (int i=0; i<counter; i++)
    counter[i] = Integer.parseInt(req.getParameter("input"+i));

    Hope this would help.
    [/quote]


IMN logo majestic logo threadwatch logo seochat tools logo