Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Jsp combo box

Posted on 2003-10-31
9
Medium Priority
?
3,273 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 53

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

722 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