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

x
?
Solved

How to set a form select object with a value?

Posted on 2005-03-24
3
Medium Priority
?
202 Views
Last Modified: 2010-04-01
need to set one of the form options as selected - these options are comming from db an I want to set the option the user prevoius selected with a value i have stored in a string!



%>
                  <select name="countryOptions">
                      <%
                            try
                            {
                        String countryname;
                        while(rs.next())
                                   {
                                    countryname = rs.getString(1);
                              %>
                        <option>
                        <%=countryname%>
                        </option>
                        <%
                                   }
                      }
0
Comment
Question by:climbingjaffa
  • 2
3 Comments
 
LVL 2

Expert Comment

by:arnon81
ID: 13625548
String selected="USA";
%>


<select name="countryOptions">
       <%
              try
              {
                  String countryname;
                  while(rs.next())
                  {
                        countryname = rs.getString(1);
                        if (countryname.trim().equalsIgnoreCase(selected))
                        {
                        %>
                                          
                                          <option SELECTED>
                                                <%=countryname%>
                                          </option>
                        <%
                        else
                        {
                                          <option>
                                                <%=countryname%>
                                          </option>
                        }
                 }
              }
0
 
LVL 2

Accepted Solution

by:
arnon81 earned 1000 total points
ID: 13625567
oops typo..missing parantheses here's the correct one

<%
String selected="USA";
%>


<select name="countryOptions">
       <%
              try
              {
                  String countryname;
                  while(rs.next())
                  {
                        countryname = rs.getString(1);
                        if (countryname.trim().equalsIgnoreCase(selected))
                        {
                        %>
                                          
                                          <option SELECTED>
                                                <%=countryname%>
                                          </option>
                        <%
                        }
                        else
                        {
                                          <option>
                                                <%=countryname%>
                                          </option>
                        }
                 }
              }
0
 
LVL 2

Author Comment

by:climbingjaffa
ID: 13625809
Thanks arnon :-) worked a treat!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Choosing the right mix of apps is very much necessary for CPAs for making the most of the latest technology through which they can boost their growth.
Herein one will find an aggregate of some of my experience building and deploying virtualization stacks both in standalone, clustered Hyper-V, clustered Hyper-V with a Scale-Out File Server (SOFS) backend, and Storage Spaces Direct (S2D).
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

580 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