Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Selection Drop Down Question

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having trouble capturing a value from a select drop down list in a page where the user has multiple choices and the page sends back the city, state, zip, and a list of plans. The problem is that the city, state and zip are captured, but if the user selects any row other than the first, the drop down list values does not get captured. Here is my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@include file="HeaderDirectives.jsp" %>
<html>
<head>
<title>Enrollment:ZipCodeList</title>
<link rel="StyleSheet" href="styles/csstemplate.css" type="text/css" media="screen">
<script language="JavaScript" type="text/JavaScript">
<!--
function submitForm(temp)
{
document.form.action.value = temp;
submit();
}

function submitForm1(temp, zip, town, usState)
{
document.form.action.value = temp;
document.form.zipcode.value = zip;
document.form.city.value = town;
document.form.state.value = usState;
submit();
}

function MM_preloadImages()
{ //v3.0
var d=document;

if(d.images)
{
if(!d.MM_p)
d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0)
{
d.MM_p[j]=new Image;
d.MM_p[j++].src=a[i];
}
}
}
//-->
</script>
<style type="text/css">
body
{
background-image: url("images/BKG_Stripes50%25.gif");
}
</style>
</head>
<body>
<table width="790" height="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#707277">
<tr>
<th valign="top" scope="col" nowrap bgcolor="#ffffff">
<table width="790" border="0" cellpadding="0" cellspacing="0">
<tr>
<th width="790" valign="top" scope="col" nowrap><img
src="images/Web_Banner_01.gif" width="610" height="75" alt=""><img
src="images/Web_Banner_02.gif" width="180" height="75" alt=""></th>
</tr>
</table>

<table width="100%" height="525" border="0" cellpadding="10" cellspacing="0">
<tr>
<th valign="top" scope="col" background="images/BKG_Stripes1805.gif">
<table width="100%" height="31" border="0" cellpadding="0"
cellspacing="0">
<tr>
<th width="739" align="right" valign="middle" scope="col"
bgcolor="#ffffff"> </th>

<th width="31" align="right" valign="bottom" scope="col"><img
src="images/Top_Rgt_Corner.gif" width="31" height="30" alt=""></th>
</tr>
</table>

<table width="770" height="450" border="0" cellpadding="10" cellspacing="0" bgcolor="#ffffff">
<tr>
<td valign="top" nowrap>
<P> </P>
<P> </P>
<fieldset><legend>Zip Code Information</legend>

<form name='form' method="post" action="enroll.do">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="ERROR"/>
<INPUT TYPE="HIDDEN" NAME="zipcode" VALUE="-1"/>
<INPUT TYPE="HIDDEN" NAME="city" VALUE=" "/>
<INPUT TYPE="HIDDEN" NAME="state" VALUE=" "/>
<table border="2" cellpadding="2" cellspacing="2">
<tr>
<th bgcolor="#ffe7c6"></th>
<th bgcolor="#ffe7c6">City</th>
<th bgcolor="#ffe7c6">State</th>
<th bgcolor="#ffe7c6">Zip</th>
<th bgcolor="#ffe7c6">Available Plans</th>
</tr>
<c:forEach items='${CityList}' var='item'>
<tr>
<td>
<input class="submit-button" type="submit" value="select"
onKlick='submitForm1("GOTO_ENROLLMENT_FORM", <c ut value='${item.zipCode}'/>,
"<c ut value="${item.city}"/>", "<c ut value='${item.state}'/>")'>
</td>
<td>
<%-- Available City --%>
<c ut value='${item.city}'/>
</td>
<td>
<%-- State --%>
<c ut value='${item.state}'/>
</td>
<td>
<%-- Zip --%>
<c ut value='${item.zipCode}'/>
</td>
<td>
<%-- Available Plans --%>
<SELECT class="input-box" name="SelectPlanID">
<OPTION value=" ">Select Plan</OPTION>
<c:forEach items='${PlanList}' var='item2'>
<OPTION value="<c ut value='${item2.contractID}'/>" >
<c ut value='${item2.planName}'/>
</OPTION>
</c:forEach>
</SELECT>
</td>
</tr>
</c:forEach>
</table>
<br>
<input class="submit-button" type="submit" value="cancel" ONKLICK='submitForm("GOTO_ZIP_CODE_SEARCH")'></input>
</form>
</fieldset>
</td>
</tr>
</table>

<table width="100%" height="31" border="0" cellpadding="0" cellspacing="0">
<tr>
<th scope="col" width="31" align="left"><img
src="images/Btm_Lft_Corner.gif" width="31" height="30" alt=""></th>

<th scope="col" width="739" align="right" bgcolor="#ffffff">
    </th>
</tr>
</table>
</th>
</tr>
</table>
</th>
</tr>
</table>
</body>
</html>

Any Ideas? Thanks!
 
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When something like this happens, the first thing to check out is to make sure that the HTML that you are sending to the page is properly formatted. When the form displays, perform a View Source to make sure that the select element and its options are correctly formatted.

If they are, then we'll probably need to see the code that you are submitting the form to.
 
Bear Bibeault
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
P.S. When posting code, be sure to enclose the code in UBB code tags (the CODE button) and be sure to check the 'disable smilies' box to keep your tags from looking so surprised.
 
Chris Cornelius
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry about that.

I looked at the generated code and this is what it looked like, looks fine to me, but then again always nice to have a second opinion.



Here is the handler code as well. Thanks in advance for your help!

 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You seem to have two drop-downs with the same name in the same form. Is that intentional? If it is, you'll get two parameters with the same name when the form is submitted, and will need to use request.getParameterValues() to get both values.

-Yuriy
 
Chris Cornelius
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes it was the intention to have more than one drop down on the page.

Thanks, that did the trick.

Chris
 
reply
    Bookmark Topic Watch Topic
  • New Topic