The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Java Help
|
Getting user input from the html page
Discuss Getting user input from the html page in the Java Help forum on Dev Shed. Getting user input from the html page Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 31st, 2000, 01:31 PM
|
|
Junior Member
|
|
Join Date: Dec 2000
Location: Ankara,Etlik,TURKEY
Posts: 0
Time spent in forums: < 1 sec
Reputation 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!!!
|

January 2nd, 2001, 01:21 AM
|
|
Junior Member
|
|
Join Date: Sep 2000
Posts: 12
Time spent in forums: < 1 sec
Reputation 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.
|

January 3rd, 2001, 06:18 PM
|
|
Junior Member
|
|
Join Date: Dec 2000
Location: Ankara,Etlik,TURKEY
Posts: 0
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
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]
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|