www.webdeveloper.com
Results 1 to 2 of 2

Thread: JavaScript/jsp help-how to refersh page after an option is selected in drop down menu

  1. #1
    Join Date
    Jul 2006
    Posts
    1

    JavaScript/jsp help-how to refersh page after an option is selected in drop down menu

    in a jsp page...there is one drop down menue that gets the velues from the detabase(this works okie)....i need to do a javascript code to refersh the page right after the user selects one of the options...and the page gets the selected value and base on that, will look into databse to disply the requried text....


    here is the code i have done..but it dosnt work,,,

    <SCRIPT LANGUAGE="JavaScript">
    function OnChange(dropdown)
    {
    //addCar.jsp is the jsp page
    var myindex = dropdown.selectedIndex
    var SelValue = dropdown.options[myindex].value
    var baseURL = "addCar.jsp?selected="
    top.location.href = baseURL+dropdown.options[myindex].value;

    return true;
    </script>
    }

    <label>
    <select name="modelCode" onchange='OnChange(this);'>
    <%
    String selected = request.getParameter("selected");

    /*here is some code to get the values and options for the drop down menu from dtabse*/


    if(selected!=null){
    prostaID = Integer.parseInt(selected);
    }
    while(i.hasNext()) //go through data base iterator i
    {
    // jsp code
    if(prostaID!=0 && prostaID==prostaDTO.getModelCode())
    {
    theCode=prostaDTO.getModelCode();
    %>

    <option value="<%=theCode%>" selected><=prostaDTO.getDesc()></option>
    <%} else{%>
    <option value="<%=theCode%>"><%=prostaDTO.getDesc()%></option>
    <%}}%>

    </select>
    </label></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td height="26"><strong>Year </strong></td>
    <%

    while(i1.hasNext())//another iterator to get the next data and just display in the page
    {
    //jsp code
    String yearModel1=prostaDTO.getYear();
    %>
    <td><%=yearModel1%></td>
    <input type="hidden" name="yearModel" value="<%=yearModel1%>">

    <% } %>


    so basicly i just need the selected value to use it to disply the year...tanx in advanceeeee

  2. #2
    Join Date
    May 2008
    Posts
    1

    i need ur help

    hi friend i need ur help to solv my prob.... I hav jsp page where there is a combo box while loading the page itself that combobox has to get the data from data base and while selecting the particular item it has to show the item details .... I think u got my point.... Plz paste the code what ever u hav for that........ in u problem u hav done dis.......... waiting 4 ur reply........

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles