Scott,

you're approach was correct. I rewrote your code to improve readability
 a little bit ) and it worked fine.
I'll include my modified code below my sig for your review.

Lance Lavandowska
Software Engineer
http://www.AgDomain.Com


<% //code to create drop down list of states... and select one of
String[] statea =
 {"AL","AK","AZ","AR","CA","CO","CT","DE","DC","FL","GA","HI","ID",
"IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO",
"MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA",
"PR","RI","SC","SD","TX","TN","UT","VT","VI","VA","WA","WV","WI", "WY" };

String[] statef =
 {"Alamaba","Alaska","Arizona","Arkansas","California*","Colorado",
"Connecticut*","Delaware","District Of Columbia","Florida*","Georgia",
"Hawaii","Idaho","Illinois*","Indiana","Iowa","Kansas","Kentucky","Louisia
na","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi
", "Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey*",
"New Mexico","New York*","North Carolina","North Dakota","Ohio*",
"Oklahoma","Oregon","Pennsylvania*","Puerto Rico","Rhode Island", "South
Carolina","South Dakota","Texas*","Tennessee","Utah","Vermont", "Virgin
Islands","Virginia","Washington","West Virginia","Wisconsin","Wyoming"
 };
%>

<FORM Action=testState.jsp>
<SELECT NAME="state">
<%
for (int i = 0; i < 53; i++)
{
    String value = (String) statea[i];
    String name = (String) statef[i];
    String selected = "";
    //change the order for your "equals" and you won't have to worry about
null pointers
    if (value.equals(request.getParameter("state")))
    {
        selected = " SELECTED";

    } else if ( value.equals("CA") ) { // CA is the default
      selected = " SELECTED";

    }
    %>
    <OPTION VALUE="<%=value%>"<%=selected%>><%=name%></OPTION>
    <%
}
%>
</SELECT>
<input type=submit>
</form>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to