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
Solved

Jsp combo box

Posted on 2003-10-31
9
3,245 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
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 51

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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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…

860 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