dropdown list in jsp
843836Sep 8 2004 — edited Aug 19 2007Hi -
I need some help.Here is my problem. I am writing drop down list in the jsp. I need to get the value of dropdown list and submit the form and again calling same jsp page. So i didn't see the same value in the
dropdown list whichever i was submitting.its giving some javascript errors.I really appreciate if anyone resolves this problem or valuble suggestions.
<script language="JavaScript">
function messageValue(){
<%
String id = request.getParameter("id");
if (id != null)
{
%>
document.myForm.id.value = <%=id%>
document.myForm.submit();
<%
}
else {
%>
var messageIndex = document.myForm.id.selectedIndex;
var selectedValue = document.myForm.id.options[messageIndex].value;
document.myForm.id.value = selectedValue;
document.myForm.submit();
<% } %>
}
</script>
<select name="id" onChange="messageValue()">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>