Hi, I have a jsp page called pager-jdbc.jsp, I don't know what's wrong with
this select option that I did, I want when the user select an option the
same jsp file is called with the category variable set to a different value
.
<%
String requestUri = request.getRequestURI();
int indexOfqm = requestUri.indexOf('?');
if (indexOfqm != -1)
requestUri = requestUri.substring(0, indexOfqm);
String category = request.getParameter("category");
%>
<%
if (category !=null)
{
category = (String)request.getParameter("flag");
}
else //If flag wasn't in the query string, set it to a default value.
{
category = "All"; //Fill in the default value here. I just used an empty
string.
}
%>
<center>
<script language="JavaScript">
function gotoFunction() {
self.location =
document.productGoto.productList.options[document.productGoto.productList.selectedIndex].value;
}
</script>
<table width="90%" cellpadding="4">
<tr>
<td>
<FORM NAME="productGoto">
<FONT FACE="Arial,Helvetica" SIZE="-2">
Select By Category:
<SELECT NAME="productList" onChange="gotoFunction()" onBlur="return
options[0].selected = true">
<OPTION VALUE="">Select a Category
<OPTION VALUE="<%= requestUri %>?category=All ">All Categories
<OPTION VALUE="<%= requestUri %>?category=Computing ">Computing
</SELECT>
</FORM>
</td>
<td width="100%">
</td>
</tr>
</table>
Discussions
Web tier: servlets, JSP, Web frameworks: JSP + javascript select ? Urgent Please ???????????
-
JSP + javascript select ? Urgent Please ??????????? (1 messages)
- Posted by: majid abdel
- Posted on: April 03 2001 15:14 EDT
Threaded Messages (1)
- JSP + javascript select ? Urgent Please ??????????? by Marcus Row on April 03 2001 16:23 EDT
-
JSP + javascript select ? Urgent Please ???????????[ Go to top ]
- Posted by: Marcus Row
- Posted on: April 03 2001 16:23 EDT
- in response to majid abdel
You could try altering the Javascript method to take a parameter. Also, change the method call attached to your onClick or onFocus Select object, so that you literally pass in the value from the Select list into the method.
E.g.
<select name="stores" size=9 onChange="buildDetails(value)" onFocus="buildDetails(value)">
<option value="valuea"/>
<option value="valueb"/>
<option value=""/>
</select>
Then, alter your event handler like this:
function buildDetails(store_id){
//now store_id points to the selected value when the user
//clicks an Option in the Select list
}
L8r
Marcus