onchange on combobox

Hi,

I would like to ask about the onchange method in javascript.

For example: if there is name combobox in my jsp page, the names inside it are retrieved from database. if I want like if I select 'lala' from combobox then it will display a table of information about 'lala' such as her address and contact no but if I never select anything then it doesn't show the table.

I've manage to find out how to do that by reloading to that page and passing the parameter name so the url is something like this: http://192.168.28.174:8080/TWIS/intranet/sample/showDetail1.jsp?samplecode=lala 

if its empty then it will be like this:
http://192.168.28.174:8080/TWIS/intranet/sample/showDetail1.jsp?samplecode=
which I don't want... I want it to be like this:
http://192.168.28.174:8080/TWIS/intranet/sample/showDetail1.jsp

cos there are a lot of pages that is linked to this page so if I change that it will become more complicated. any ideas how to do that? thanks.

here is my sample code:
<select name="samplecode" size="1" id="select" onchange="location.reload('showDetail1.jsp?samplecode='+this.options[this.selectedIndex].value)">
<option selected><%= request.getParameter("samplecode")%></option>
<option></option>
<%
        conn = db.getConnection();
        stmt = conn.createStatement();
        sql="select sample from sampledefinition";
        rs=stmt.executeQuery(sql);
        while(rs.next()){
%>
       <option value="<%=rs.getString("sample")%>"><%=rs.getString("sample")%></option>
       <%}
            rs.close();
            stmt.close();
            conn.close();
      %>
     </select>
widiyantoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

minichickenCommented:
You can do somoething like this: A form which will submit to it self. and on your ASP page you just use Request.Querystring to get the value.

<form name="form1" method="get" action="">
  <select name="select" onChange="form1.submit()">
    <option>Value1</option>
    <option>Value2</option>
    <option>Value3</option>
  </select>
</form>
0
widiyantoAuthor Commented:
thanks for the quick response.. but I'm using jsp.. :D
0
minichickenCommented:
Oh sorry, but it will work basically the same way, on your JSP page, use the method to request values from the URL querystring.

<form name="form1" method="get" action="">
  <select name="select" onChange="form1.submit()">
    <option>Value1</option>
    <option>Value2</option>
    <option>Value3</option>
  </select>
</form>
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

steve_bagnallCommented:
Hi,

I think this is what you're looking for..

request.getParameter("select");

Cheers, Steve
0
widiyantoAuthor Commented:
ok thanks....
I tried the code and it works... but when I want to link to that page, I got http error--404 eventhough I put the file on the correct page  or sometimes it java nullpointer error... can help me? thanks.
0
minichickenCommented:
How about this?

<form name="form1" method="get" action="showDetail1.jsp">
  <select name="select" onChange="form1.submit()">
    <option>Value1</option>
    <option>Value2</option>
    <option>Value3</option>
  </select>
</form>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
widiyantoAuthor Commented:
ok.. Thanks...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.