JSP + javascript select ? Urgent Please ???????????


Web tier: servlets, JSP, Web frameworks: JSP + javascript select ? Urgent Please ???????????

  1. 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


    <script language="JavaScript">
    function gotoFunction() {
           self.location =

    <table width="90%" cellpadding="4">
    <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
    <td width="100%">

  2. 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.
    <select name="stores" size=9 onChange="buildDetails(value)" onFocus="buildDetails(value)">
    <option value="valuea"/>
    <option value="valueb"/>

    <option value=""/>

    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