Win a copy of Kotlin in Action this week in the Kotlin forum!
    Bookmark Topic Watch Topic
  • New Topic

dropdown menu default value from table  RSS feed

 
Hak Khan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi JSP experts,

I have query a table and retrieve 4 columns such as REGION, REGULAR_STEPS, MULTIPLE_STEPS, and DB_NAME.

In a JSP page I have to display all retrieved columns within a html table.
SOMETHING LIKE THIS:

REGION | REGULAR STEPS | MULTIPLE STEPS | DB NAME
DEV | N | Y | SALES_DB
QUA | Y | N | MARKTNG_DB
NOTE: REGION "DEV" pointing to or currently using SALES_DB
OR
REGION "QUA" pointing to or currently using MARKTNG_DB

1. REGION will display as a simple display field.
2. REGULAR_STEPS column would display as two radio buttons (ON or OFF)
based on its value. For instance, if it has a value "Y", than ON radio
button has to be checked by default. If it has value "N", than OFF radio
button has to be checked by default.
3. MULTIPLE_SPETS - same as 2.

4. DB_NAME contains 5 different DB names, and it should display in a dropdown menu with the default value based on REGION is pointing to currently i.e. in the above example.

All I want is how to mention or display a dropdown menu in JSP within html

I'm trying something like this AFTER my query executed.
<%
String rbdb = "";
rbdb = resultSet.getString(4);
%>

<%
if (rbdb == "SALES_DB")
{
%>
<form action="dummy" method="post">
<select name="dev10dd">
<option value="SALES_DB" selected>SALES DATABASE</option>
<option value="ABC_DB">ABC DATABASE</option>
<option value="XYZ_DB">XYZ DATABASE</option>
<select>
<%
}
%>

RESULT - Its not displaying my dropdown menu.

If somebody can help me here would be highly appreciated
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66188
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Have you performed a View Source from the browser to see the HTML that is being sent? is it what you expected? Is it properly formed?

That should be your first debugging step.
 
Hak Khan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Report post to moderator
I did check the source view as well, I have also added an else condition with a println testing message.

The database name coming from table as Ratadev. I have put this value into a variable and than check if it is Ratadev, than draw my dropdown menu but its always going in else condition. Here is my code

rbdb = resultSet.getString(4);
I did check at this point, rbdb value is Ratadev
NOTE: I have also tried with if (rbdb == "RATADEV")


<%
if (rbdb == "Ratadev") {
out.println("<td><form action=\"dummy\" method=\"post\"><select name=\"dev10dd\"><html ption value=\"RATADEV\" selected>RATADEV</option><html ption value=\"RATAQUA\">RATAQUA</option><html ption value=\"RATASUP\">RATASUP</option><html ption value=\"RATASTAG\">RATASTAG</option><html ption value=\"RATAPRTY\">RATAPRTY</option></select></form></td>");
}
else {
out.println("Testing if condition");
}
%>
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66188
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
I did check the source view as well ...


Don't keep us in suspense... what was the outcome of your check. Was all the HTML that you expected there? Was it properly formatted?
 
Nikhil Menon
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi aren't you guys discussing on the same topic?
http://www.coderanch.com/forums/

You can see in your if condition you have used reference equality instead of value equality.

Nikhil
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66188
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Yes, same issue. Closing.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!