Solved

Getting correct value from multiple rows

Posted on 2008-06-17
6
168 Views
Last Modified: 2010-03-30
hi guys

On my screen i have three rows (UserVO) , like this

ID   NAME    GROUP
--   ----    -----
1     Jay     T            
2     Jay     I            
3     Jay     P            


ID and NAME are text boxes and GROUP is a dropdown. So the basic functionality is
if user selects 'I' or 'P' from GROUP drop-down, Name field should become readonly. When user selects
T, the Name field should again become editable text box. so when user selects I or P, Jay becomes readonly and when user selects T, Jay becomes editable.

Basically i am displaying the above rows using java code (I am putting all the individual rows in a List and
iterating throught the list and displaying them ;

for(int row=0 ; row < List.size();row++)
{
UserVO user = (UserVO) List.get(cnt);
// get Group value
String group = form.getGroup();  getting the Group value here
if(groupType = I || groupType = P)
{
Disable the Name field
}

Basically here i want to get the Group value from individual rows and check if it is I or P or T individually for each row and then disable the name field for that row


but the problem is String group = form.getGroup(); will give the group value correctly just for the
first row.   The second and third row dont work because form.getGroup();   doesnt recognize those rows, so i am thinking may be i should pass some index instead of doing  String group = form.getGroup();

for(int row=0 ; row < List.size();row++)
{
...
String group = form.getGroup()[index of 1st / 2nd /3rd row]}
but i am not sure how to impliment this , any ideas will be greatly appreciated

thanks
J
0
Comment
Question by:jaggernat
  • 3
  • 2
6 Comments
 
LVL 9

Expert Comment

by:sanjooz
ID: 21809791
It works as expected. I bet your group drop down lists has the same name. So when you get the values with form.getGroup(), you get value of the last group drop down element.

To fix this, you will have to use an array(for example group[]) or different names for drop down lists (group1, group2 etc)
0
 
LVL 10

Author Comment

by:jaggernat
ID: 21809980
but if i have like 100 rows, i cannot have group1, group2 ...group100... thats practically not possible.
i want to use a single form.getGroup() and get the correct value for each row..

is that possible?
thanks
J
0
 
LVL 9

Expert Comment

by:sanjooz
ID: 21809985
then you can use array group[]
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 10

Author Comment

by:jaggernat
ID: 21810023
ok..can you give me some sample code so i can understand what you are saying

thanks
J

0
 
LVL 11

Assisted Solution

by:Manish
Manish earned 100 total points
ID: 21811022
can you try this..
give group name same for all row. Group should contain id in it.
Get the String array in java/jsp.
While iterating List test whether array contains group which has id in it. If match-diable/enable.
0
 
LVL 9

Accepted Solution

by:
sanjooz earned 400 total points
ID: 21826747
Look at the code. Replace <input type="text" > with whatever element you are using. On the other end (Servlet), you can obtain value of these elements as

String textArray = (String[]) thisForm.get("text");
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">

<html lang="en">

<head>

    <title><!-- Insert your title here --></title>

</head>

<body>

    <form name="testform" method=post action=test1.php>

        text1 : <input type=text name=text[] /> <BR>

        text2 : <input type=text name=text[] /><BR>

        text3 : <input type=text name=text[] /><BR>

        text4 : <input type=text name=text[] /><BR>

            <input type=submit name=submit value=submit>      

    </form>

</body>

</html>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unable to start eclipse ? 17 128
unix in java example 9 52
compre toata in where clue oracle 4 55
tomcat not starting 6 24
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now