?
Solved

selecting data from the database with drop down list for update

Posted on 2005-04-01
6
Medium Priority
?
185 Views
Last Modified: 2010-04-01
Hi there i asked this question already but left it alone gone back to fix it now and the stuff i was told to try isnt working i have 2 pages a change.jsp and changed.jsp

In change i have text boxes and drop down boxes containing member information i have the information coming from the database inserting into the text boxes, but i also have drop down boxes and when the user clicks on the page to update their details i want the drop down box already selected with their details here is some code:

---------------------------------------------
<tr>
                                <td align="right" valign="bottom" bgcolor="#ffffff" class="subtitle"><div align="left"><b>Town:</b></div></td>
                                <td colspan=3 align="left" valign="bottom">
                                  <input name="Town" size="35" maxlength="25" tabindex="10" value="<%=rs21.getString ("Town")%>">

-----------------------------------------------------------
This is how im doing it for the text box

----------------------------------------------------------------

this is the code for the drop down box


                                </td>
                              </tr>
                              <tr>
                                <td align="right" valign="bottom" bgcolor="#ffffff" class="subtitle"><div align="left"><b>County:</b></div></td>
                                <td colspan=3 align="left" valign="bottom">
                                  <select name="County">
                                    <OPTION value= "County" Selected>County</OPTION>




                                   <option value="Carlow">Carlow</option>
                                    <option value="Cavan">Cavan</option>
                                    <option value="Clare">Clare</option>
                                    <option value="Cork">Cork</option>
                                    <option value="Donegal">Donegal</option>
                                    <option value="Dublin">Dublin</option>
                                    <option value="Galway">Galway</option>
                                    <option value="Kerry">Kerry</option>
                                    <option value="Kildare">Kildare</option>
                                    <option value="Kilkenny">Kilkenny</option>
                                    <option value="Laois">Laois</option>
                                    <option value="Leitrim">Leitrim</option>
                                    <option value="Limerick">Limerick</option>
                                    <option value="Longford">Longford</option>
                                    <option value="Louth">Louth</option>
                                    <option value="Mayo">Mayo</option>
                                    <option value="Meath">Meath</option>
                                    <option value="Monaghan">Monaghan</option>
                                    <option value="Offaly">Offaly</option>
                                    <option value="Roscommon">Roscommon</option>
                                    <option value="Sligo">Sligo</option>
                                    <option value="Tipperary">Tipperary</option>
                                    <option value="Waterford">Waterford</option>
                                    <option value="Westmeath">Westmeath</option>
                                    <option value="Wexford">Wexford</option>
                                    <option value="Wicklow">Wicklow</option>
                                    <option>None of the Above</option>
                                  </select>
                                </td>
                              </tr>

0
Comment
Question by:acslater
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 

Author Comment

by:acslater
ID: 13680225
any replys Tim i know you can help!!!
0
 
LVL 4

Accepted Solution

by:
orhanbaba earned 1000 total points
ID: 13680232
<OPTION selected ><%=rs21.getString ("Town")%></OPTION> if this isthe first line it will be shown as selected
0
 
LVL 4

Expert Comment

by:orhanbaba
ID: 13680253
sorry it will be  last line
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Expert Comment

by:orhanbaba
ID: 13680265
for example
      <select name="County">
                                    <OPTION value= "County" Selected>County</OPTION>//selected
      <option value="Carlow">Carlow</option>
                                    <option value="Cavan">Cavan</option>
                                    <option value="Clare">Clare</option>
                                    <option value="Cork">Cork</option>
                                    <option value="Donegal">Donegal</option>
<OPTION selected ><%=rs21.getString ("Town")%></OPTION> //it will be selected
       <option>None of the Above</option>
                                  </select>
both variable has selected value but last one will be shown
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13680344
I thought we already covered this in:  http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21371125.html

--------------

 If you store all the counties as Strings in an array:

<%
    String[] countyArray = { "County", "Carlow", "Cavan", ...etc..., "Wicklow" } ;
%>

then, you should be able to do:

                                  <% String county = rs21.getString( "County" ) ; %>
                                  <select name="County">
                                  <%  for( int i = 0 ; i < countyArray.length ; i++ ) {
                                        <OPTION value= "<%= countyArray[ i ] %>" <%= county != null && county.equals( countyArray[ i ] ) ? "SELECTED" : "" %>><%= countyArray[ i ] %></OPTION>
                                  <%  } %>
                                    <option <%= county == null ? "SELECTED" : "" %>>None of the Above</option>
                                  </select>

which is neater :-)
0
 

Author Comment

by:acslater
ID: 13680437
Its ok the first one works and its only one line of code

<OPTION selected ><%=rs21.getString ("Town")%></OPTION>
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
I originally wrote this article to compare SARDU and YUMI, but have now added Easy2Boot, since that is the one I currently use and find the easiest to create and alter.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

764 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