Drop down box query

Hi
Iam retreving certain results from database and displaying them in a JSP page.Against each record there is a drop down box which contains 2 values 'active' and 'inactive'. I can select either of these values for all records and then click on 'submit' button.After clicking submit button Iam calling another jsp which will retrive the values changed in drop down list.My query is how do I get the multiple values changed in drop down in next page and update the database with these values.

Thanks in advance
kalyanmAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimYatesCommented:
Give your drop down boxes different names (based on the id of the row)?

ie:

Row 1
<input type="select" name="1_act">
    <option value="on">activate</option>
    <option value="off">deactivate</option>
</input>
Row 2
<input type="select" name="2_act">
    <option value="on">activate</option>
    <option value="off">deactivate</option>
</input>

then, in your second JSP, you can just go through your items that you displayed to the user, and see if they were set to on or off...

<%
    for( int i = 0 ; i < rows.size() ; i++ )
    {
        String value = request.getParameter( ( i + 1 ) + "_act" ) ;
        if( value != null )
        {
           out.println( "Row " + ( i + 1 ) + " was set to " + value ) ;
           // db stuff here to set this value in the database for row "i"
        }
    }
%>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kalyanmAuthor Commented:
Tim
Thanks for that.But I have a problem Iam printing bewlo the section of code which generates drop down list for all rows and problem is that I cannot give name from option list based of a row as listed below and it generates the same drop down list as many as no of rows as it is in while loop.I wanted to get these into next page and update
<%
      
      ResultSet rslt = null;
        StringBuffer make = new StringBuffer();       
      
        try {                                                                    
                String myDriver="sun.jdbc.odbc.JdbcOdbcDriver";
            String url = "jdbc:odbc:Momqts";
            Class.forName(myDriver);
                Connection conn = DriverManager.getConnection(url);
                Statement stmt = conn.createStatement();
            rslt = stmt.executeQuery("SELECT Emp_no,project_id,Emp_name from members order by " + columnName + " desc");
 
                if(rslt!=null)
            {
                   
                  while(rslt.next())
                  {
                             
                         String mqrid =rslt.getString("Emp_no");
                         String mdate=rslt.getString("project_id");
                         String mid=rslt.getString("Emp_name");
                         make.append(mqrid);
                         make.append("\t");
                   make.append(mdate);
                   make.append("\t");
                     make.append(mid);
                         make.append("\n");
                  
             
%>

<tr>
                       
                  <td width="20%"><%=mqrid%></td>
                  <td width="20%"><%=mdate%></td>
                  <td width="20%"><%=mid%></td>
                        <td width="40%">
                        <select name=emp1>
                        <option value="active" selected>active</option>
                        <option value"inactive">inactive</option>
                        </select>
                        </td>
                  
0
TimYatesCommented:
Why not change:

                        <select name=emp1>

to

                        <select name="<%= mqrid + "emp1" %>">
0
kalyanmAuthor Commented:
Tim
Thanks for advice,i will try with this...
Do I need to set the option to 'on' or 'off' as you have previuosly suggested also Can you please elaborate on the code you have given for 2nd JSP..ie. how do I get rows.size() ?
<%
    for( int i = 0 ; i < rows.size() ; i++ )
    {
        String value = request.getParameter( ( i + 1 ) + "_act" ) ;
        if( value != null )
        {
           out.println( "Row " + ( i + 1 ) + " was set to " + value ) ;
           // db stuff here to set this value in the database for row "i"
        }
    }
%>
and after I get these parameters I have to update the database with the values that have been selected as 'active' only.please advice
0
kalyanmAuthor Commented:
I hve resolved this and can be closed now
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.