Solved

Jsp combo box

Posted on 2003-10-31
9
3,266 Views
Last Modified: 2012-06-21
I'm having trouble with a jsp search page in which I have 2 combo boxes and one submit button.
Both combo boxes retrieve data from an access db.
The problem is how to specify from which combo the request is sent.
I tried this piece of code but it didnt work:

if (request.getParameter("combo1") != null) {
execute this code;

} else if (request.getParameter("combo2") != null) {
execute that code;
}

Thanks for your help.
0
Comment
Question by:dtaifour
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 5

Expert Comment

by:rajaamirapu
ID: 9662540
Add a entry -1 as the first entry in both the combo boxes.Then you will know which entry is selected
0
 

Author Comment

by:dtaifour
ID: 9663185
Thanks but I dont see what you mean clearly ...... could you plz right on the code ?
0
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 9669519
The if condition looks ok for me, what if you try to output the parameter combo1 and comb2?

Example:

System.out.println("combo1 = " + request.getParameter("combo1"));
System.out.println("combo2 = " + request.getParameter("combo2"));

And if needed, you can post your jsp scripts here.

regards
0
WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

 
LVL 5

Expert Comment

by:rajaamirapu
ID: 9669770
Add like this
 <select size="1" name="combo1">
    <option value="-1"></option>
    <option value="34">34</option>

    <select size="1" name="combo2">
    <option value="-1"></option>
    <option value="34">34</option>

0
 
LVL 5

Expert Comment

by:rajaamirapu
ID: 9669774
I am mentioning about this
<option value="-1"></option>
0
 

Author Comment

by:dtaifour
ID: 9680173
The problem is not about knowing which entry is selected but rather which combo is selected.
Therefore, it excutes both codes and display all the html that comes with both combos.
0
 

Author Comment

by:dtaifour
ID: 9681829
hi,
I have finally found the solution, the code goes like this:

if ((request.getParameter("NameCombo") != null) && (request.getParameter("DeptCombo").equals("Select by Department"))) {
execute this code;
}

if ((request.getParameter("DeptCombo") != null) && (request.getParameter("NameCombo").equals("Select by Name"))){
execute that code;
}
the problem was to get the parameter sent by the combo that was not selected.
Anyway thanks for your comments.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12511991
PAQed, with points refunded (50)

modulo
Community Support Moderator
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question