Select results from Database

Hopefully this is a simple question.  I’m working on a JSP page that will search a database and return the results based on the search.  After the results have been returned, I need to allow the user to select one of the results and then be directed to the appropriate page based on that selection.  I’ve been able to retrieve the resultSet and create a radio button beside each one, however I’m not sure how to pass the information of the result to the next page.  Please see the example code I’ve provided.  What do I need to change here?  Thanks




while (rs.next()) {
       
         String project = rs.getString(1);
         String testname = rs.getString(2);
         String testid = rs.getString(3);
         String description = rs.getString(4);
         %>

       <table border ="0" cellspacing="1" cellpadding = "1">
<input type = "radio"
name = "result"
value = testname
onClick="submit()" ><h1>Project Name: <%=project%>     , TestName:         <%=testname%> , Description: <%=description%></h1> <BR></input>
 
  <%
jhughes4Asked:
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.

aleksmezaCommented:
 You can use a form instead of onClick submittion, and you add a boton for submit, and also in the same cicle of the result set you can create this form, here's my code suggestion:

   <!-- in this form I'm assuming that you have a javascript function name submit() -->
  <form name="yourForm" method="POST" action="javascript:submit()">
     <table border ="0" cellspacing="1" cellpadding = "1">
     <% while (rs.next()) {
            String project = rs.getString(1);
            String testname = rs.getString(2);
            String testid = rs.getString(3);
            String description = rs.getString(4);
      %>
        <input type = "radio" name = "result" value = testname>
           <h1>Project Name: <%=project%>     , TestName:         <%=testname%> , Description:
           <%=description%></h1> <BR></input>
     <% } // while %>
        <input type="submit" name="Go" value="go" >             
     </table>
     
  </form>

   I think this is a clearly way to do this, hope this help :)

   Alex Meza
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
jhughes4Author Commented:
On the next jsp page when I do request.getParameter( "result" )) it just returns testname as opposed to the value of testname.

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.