Solved

Jsp combo box

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

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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now