•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 456,564 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,560 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 1100 | Replies: 2
![]() |
•
•
Join Date: Oct 2007
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
The class that my bean uses has an array textFields[407]. I have 407 textfields in my jsp file. I used a loop to make the textfields. So, it looks something like this:
The problem lies in the NAME. What should be its syntax so i can say that I am passing the value of the ith textField in the jsp file to the ith element of the array in the bean?
Is this possible? or should I do another kind of approach?
JSP Syntax (Toggle Plain Text)
<%for ( int i = 0; i < lineCount; i++ ) {%> <INPUT TYPE="TEXT" NAME="textFields"+i SIZE="4" MAXLENGTH="7" VALUE=<%= transaction.getTextField(i)%>> <%}%>
The problem lies in the NAME. What should be its syntax so i can say that I am passing the value of the ith textField in the jsp file to the ith element of the array in the bean?
Is this possible? or should I do another kind of approach?
Last edited by Melzy : Oct 23rd, 2007 at 9:26 am.
•
•
Join Date: Oct 2007
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
please help me.
I tried:
NAME="textFields["+i+"]"
NAME="textFields["+<%=i%>+"]"
NAME="textFields[i]"
NAME="textFields[<%=i%>]"
I'm running out of ideas. Could this approach be impossible? but it would be hell if I am gonna give 407 unique names in the bean for the 407 textFields. That isn't approprite. there should be an easier way.
I tried:
NAME="textFields["+i+"]"
NAME="textFields["+<%=i%>+"]"
NAME="textFields[i]"
NAME="textFields[<%=i%>]"
I'm running out of ideas. Could this approach be impossible? but it would be hell if I am gonna give 407 unique names in the bean for the 407 textFields. That isn't approprite. there should be an easier way.
•
•
Join Date: Aug 2007
Posts: 74
Reputation:
Rep Power: 2
Solved Threads: 9
The given code might help...
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="person.Person" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<%
Person [] persons = new Person[3];
persons[0] = new Person("aaa","aa","dfdd");
persons[1] = new Person("vvv","vvv","dfgd");
persons[2] = new Person("ggg","gg","dty");
%>
<body>
<%
int i=0;
for( i=0; i<persons.length; i++){
String firstName = persons[i].getFirstName();
%>
<input type="text" name='f<%=i%>' value="<%=firstName%>">
<br>
<%
}
%>
</body>
</html>![]() |
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- keep getting "unitialized value in array element" (Perl)
- What relation does **indirection operator have with Multidimensional Arrays (C++)
- C++ pass 2d array into function (C++)
- not-a-virusadware (Viruses, Spyware and other Nasties)
- Array Values not found in Methods (Java)
- how to pass a array from asp to javascript (JavaScript / DHTML / AJAX)
- c language problm, how to pass pointer to a function (C)
Other Threads in the JSP Forum
- Previous Thread: struts-html:checkbox default checked
- Next Thread: problem in importing package


Linear Mode