Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

selecting data from the database with drop down list for update

Posted on 2005-04-01
6
Medium Priority
?
188 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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

"Day by day nothing changes but when u look back, everything is different". That quote precisely describes today’s digital era. For example, you may not have noticed the change, but Voice Search is now all around us.
Don’ts and Dos are two important end products of software testing basics that a tester needs to regard. This article attempts to explain the principles of both.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

564 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