Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to retrieve values in the appropriate textboxes  RSS feed

 
Omar Ali
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am facing some difficulties in retrieving the values from the DB and displaying them in the textboxes. I am having a checkbox and two text fields which will iterate for 5 times. The value of the first checkbox is "S" and the title should be Spouse and the second textbox should be "D1" and the title will be Dependent 1. The iteration will be to the 5th the value which will be D4 and the title will be "Dependent 4". The problem is that when the Spouse entries are empty and they has no entries in the DB, the columns should be blank and the data should be retrieved in the second iteration from the DB for the other records (ex. D1). The values should in the second row where actually in this code, they will be placed at the beginning in the Spouse textboxes and the code will not skip the Spouse if it is blank and will retrieve the dependent records in it. My code is:
<%

for (int i =1; i<=5; i++)

{

String Name = "";

String Relationship= "";

if (myResultSet.next())

{

Name = myResultSet.getString("NAME");

RelationShip = myResultSet.getString("RELATIONSHIP");


}

%>
<tr>
<td>
<input type="checkbox" id="depen<%=i%>" name="depen<%=i%>" value="<%=RelationShip%>" onclick="Enable(this)"></td>
<td><%=RelationShip%></td>
<td><input type="text" id="name<%=i%>" name="name<%=i%>" value="<%=sz_Name%>"></td>
<%
if (RelationShip.equals("S"))

{

RelationShip = "D" + i;
}
else

{

RelationShip = "D" + i;
}

}

%>
Can anyone help in this.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not following. Can you write pseudocde that explains your desired algorithm. Forget about JSP and Java. Just list the steps. For example:

- for each employee
--- for each of up to 5 dependents
------ if dependent is spouse, do x
------ if dependent is other, do y
------ if no dependent, do z
 
Omar Ali
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When a member views the form, he will find 5 checkboxes and a number of text fields to enter the information each for each member in his family like name, tel no., address, gender ..etc. The first checkbox by default should have the value "S" for Spouse and the other checkboxes will have values "D1" for "Dependent 1", "D2" for "Dependent 2"..etc. If he wants to enter the Spouse information, the member will tick the first checkbox and he will enter the fields and the same for the others.
Now, after entering the values, I am facing difficulties while retrieving the values if the member didn't enter the Spouse details and he had entered only for example dependent 1 information. My code will retrieve the dependent information in the Spouse fields which are incorrect.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!