|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
|
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
Thank you very much. URL 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] |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Getting user input from the html page |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|