Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trouble passing pre-selected options

Status
Not open for further replies.

riches85

Programmer
Nov 13, 2002
59
US
I have a jsp that is used to update a persons information by pulling the persons data into a form field so that they can be edited. i also have it so certain options in a select box are preselcted. My problem comes when i submit the page to the validating stage. It keeps coming back saying I need to enter the info. the same validation code is used when a person enters new information so im assuming that the form is having trouble passing pre-selected values. Has anyone seen this before? My validation code looks like follows:


String[] Positions = request.getParameterValues("Positions");

else if( Positions == null ) {
%>
<form method=&quot;post&quot; action=&quot;Edit_Player.jsp?edit=notnull&quot;>
ERROR!<br />A Position is Required!<br /><br />
<input type=&quot;submit&quot; value=&quot;Go Back&quot;>
<%
}
 
Hi riches:

When you call

String[] Positions = request.getParameterValues(&quot;Positions&quot;);

Are you trying to get all values in the list?
It can sound stupid, but, are you sure that the input type select's name is &quot;Positions&quot;? otherwise, it must return all the values (not the selected one) in the list, or an empty vector instead, not a null. To retrieve the selected value you must call

String position = request.getParameter(&quot;Positions&quot;);

That will return null if no value is selected.

I'm not sure if I misunderstood your post.

Hope it helps.

Pedro.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top