Change Drop Down from Other JSP/Servlet/Bean

I am wanting to have a select box populate from a database query based on the information pulled from another select box as the user chooses it (ie a user chooses a state and the city choices populate or something like that). I am using JSP, Servlets and Beans. Seems that I need to us JSF, but I was wondering if there is another way or better way.
Thanks for the thoughts.

user12081556 wrote:
I meant to put in my question above, aren't jsf tags just imbedded in some jsp/html code?Not jsp code no. I don't know whether it's possible to use jsf and jsp together, but I wouldn't try.
While JSP has evolved over time from Html and Java code mixed together to standard tags responsible mostly for displaying the data, it's still an old "hack" that compiles jsp pages into servlets.
JSF at least alleviates some of those problems and works nicely with proper xhtml formatted views too (and there's facelets etc. etc. etc.).
Granted, if you're shown some jsp tags and jsf tags, you might not appreciate the difference in the technologies.

Similar Messages

  • How do I get about:config and other about: addresses to drop down from URL bar?

    How do I get about:config and other about: addresses to drop down from URL bar?
    It's a pain having to retype them in full... not sure why there is no easier interface to them.

    hello, you can bookmark the sites for faster access.
    [[How to use bookmarks to save and organize your favorite websites]]

  • JSP- Servlet-- Bean-- JSP how to implement

    I have problem.
    My JSP will take a emplyee id .
    Now I want to show all the values regarding that employee in a JSP(JSP form) from the DB(Oracle).
    So Iam planning like
    JSP-->Servlet-->Bean-->JSP
    So my doubts are.
    1. Is it correct approach
    2.If it is correct then which part of the flow connects to DB and stores the value before putting to JSP.
    Iam using Tomcat 4.31
    Plz help me

    I have problem.
    My JSP will take a emplyee id .
    Now I want to show all the values regarding that
    employee in a JSP(JSP form) from the DB(Oracle).
    So Iam planning like
    JSP-->Servlet-->Bean-->JSP
    So my doubts are.
    1. Is it correct approach
    2.If it is correct then which part of the flow
    connects to DB and stores the value before putting to
    JSP.
    Iam using Tomcat 4.31
    Plz help meHI
    What you are probably proposing is an MVC design pattern. I wonder if u have heard of the struts framework. Sruts uses MVC design pattern wherein the servlet u are talking about acts as a controller(C) and the bean acts as the model(M) .The JSPs present the view(V). Hence the name MVC.
    Your approach is right. First get the employee ID from the jsp and get the corresponding data from database(This logic u implement in the servlet). Then save the fetched data in a bean so that the result jsp can fetch data from it.
    Now this is not a strict MVC approach.
    Learn more about struts. It presents a much more cleaner solution.

  • Sample jsp servlet bean (MVC) code

    We want to look into the JSP/Servlet/Bean area for our next project. We wish to understand the technology and as such want to hand build simple applications, and as such do not want to use JDeveloper just yet.
    We have searched and searched for suitable material but cannot anywhere find a sample application that :
    A. Lists contents of a databse table
    B. Each item in trhe list is a link to a page that allows that item, to be edited.
    C. A new item can be added.
    D. Uses the MVC model of JSP/Servlet and bean (preferably with no custom tags)
    There are examples that are too simplistic and do not cover the whole picture. Having spent over 100 GBP on books lately, only to be disappointed with the examples provided, we need to see some sample code.
    The samples provided by Oracle are too simplistic. They should really have provided ones built around the EMP and DEPT tables.
    Anyone know where we can get hold of this sample code.

    At the risk of sounding really dumb the examples are just too complex. There does not appear to be anywhere on the web where I can find a simple JSP/servlet/bean example of the type I described. There is enouigh material describing each individual component, but what I need is an example to cement the ideas, but the ones suggested are too much for a newbie. Even the much vaunted Pet Store thingy causes my eyes to glaze over.
    I dont expect anyone to have written something with my exact requirements, but surely to goodness there must be something that:
    1. On entry presents a search form on a table (e.g. EMP)
    2. On submission list all rows in EMp matchiung the criteria.
    3. The user can either click the link 'Edit' which opens up a form dispalying the row allowing the user to edit and save the changes, or click the 'New' button to show a blank form to create a new EMP.
    All this via a Controller servlet, with the database logic handled by a java bean, and all the presentation done via JSP.
    To me this is the most obvious and instructive example of this technology, but after days of trawling the web, and looking through a number of books, I cannot find such a thing.
    CGI with Perl DBI/DBD was a breeze to work with compared to this stuff ..... maybe ASP with SQL/Server would be a more fruitful use of time.

  • Drop down menu in JSP

    Hi,
    I am trying to set up a drop down menu on a jsp page and have another drop down menu to pull up values from the database depending on the selection from the first drop down menu.
    I have spent a lot of time trying to get this thing working but had no success.
    Please help.
    Thanks,
    Prasoon

    Please see my other reply located at:
    Dependent Drop Down Lists

  • I can not get rid of a iCloud address in my drop-down from mail window

    Email address wrong in mail on drop-down from window. The email was created as an alias in icloud but one leter is a mistake. I corrected this mistake with new address but can not get rid of old address and its not in icloud mail either.
    Can you help.
    End of tether
    Morgan

    morgan d falcon wrote:
    drop-down from window
    Sorry, I misunderstood. Apple calls it "the From pop-up menu" — see under Set the From address in this Apple doc:
    Mail (Mavericks): Address messages
    ...Presumably if follow the instructions there and set "Send new messages from" to the address you want, you won't then need to click on the "From pop-up menu" and see the incorrect address.
    Perhaps someone else here knows how to remove the incorrect address completely — or try clicking on "Manage your Apple ID" here:
    My Apple ID

  • How to display information from database using drop down list in JSP?

    Hi all.
    Like the tile above suggest, I'm having difficulty in obtaining the data as well as displaying them in a drop down list.
    For example: If i were to have the following in my database:
    SerialNo Food
    1 Bread
    2 Milk
    3 Butter
    The drop down list should look like the following:
    [Bread][\/]
    [Milk]
    [Butter]
    How do i go around coding it in JSP?
    Thanks in advance.
    C.K

    Hai Please try the following code
    You have to make some changes according to your system i am using
    MSSqlserver Driver change the class name and the connection string
    for your need
    <HTML>
    <HEAD>
    <%@ page language="java" import="java.sql.*"%>
    <LINK href="../theme/Master.css" rel="stylesheet" type="text/css">
    <TITLE>ListDrop.jsp</TITLE>
    <%!Connection con;
         %>
    </HEAD>
    <BODY>
    <select>
         <%
              try {
                   Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");\\Here you specify the Class Nale
                   con = DriverManager
                             .getConnection(
                                       "jdbc:microsoft:sqlserver://javaserver:1433;DatabaseName=karthi",
                                       "sa", "sa");\\here Connection string
                   ResultSet rs;
                   Statement st = con.createStatement();
                   rs = st.executeQuery("select SerialNo,Food from Foods");
                   while (rs.next()) {
    %>
         <option value='<%= rs.getString("SerialNo") %>'><%= rs.getString("Food")%></option>
         <%
              } catch (Exception e) {
                   e.printStackTrace();
    %>
    </select>
    </BODY>
    </HTML>

  • Reading from HTML Drop-Down Menu into JSP

    Hi folks. I'm am just delving into JSP, and I have a very basic question. I've been looking around the internet for a good tutorial on how to read HTML form input data into my JSP page. I really haven't found anything, and was hoping that you could provide me with some good resources. I want to have just a basic HTML drop-down menu with a SQL query executed based on the menu selection. The selection from the drop-down menu should go into the SQL query where "Shawnee" currently is. Here is my JSP code:
    <%@ page contentType="text/html;charset=windows-1252" import="java.sql.*"%>
    <%     
    try
         Class.forName("net.sourceforge.jtds.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:jtds:sqlserver://khrcs4:1433/Mail_List;user=xxxx;password=xxxx");
           System.out.println("success");
           Statement st = con.createStatement();
           ResultSet rs = st.executeQuery("select * from contacts where class like '%First Time Home Buyer Lenders%' and served like '%Shawnee%' order by company");
           while(rs.next())
              out.println(rs.getString(3)+"<br>"); //company
              out.println(rs.getString(12)+"<br>"); //address
              //out.println(rs.getString(13)+"<br>"); //address2
              out.println(rs.getString(8)+", "+rs.getString(9)+" "+rs.getString(14)+"<br>"); //city, state zip
              out.println(rs.getString(7)+"<br><br>"); //phone
    catch (Exception ex)
         ex.printStackTrace();
    %>

    ArrayList recList = new ArrayList();
    while(rs.next())
         recList.add(rs.getString(3));
    put the recList in the session.
    session.setAttribute("allrecords",recList);
    Then in your jsp, get the recList from the session and loop it,
    ArrayList recList = (ArrayList)session.getAttribute("allrecords");
    for (var i=0; i < recList.size();++i){
         addOption(document.getElementById("drop-down box name"), valarray, valarray[i]);
    function addOption(selectbox,text,value)
         var optn = document.createElement("OPTION");
         optn.text = trim(text);
         optn.value = trim(value);
         selectbox.options.add(optn);

  • Dynamically create drop down box with JSP

    Hi,
    I hope this is not a repeat post, I have search the forum and a posting has not jumped out at me. I am making a jsp that dynamically constructs a custom SQL query.
    I have a number of text boxes with an id, my jsp page calls a servlet, the servlet reads the contorl id and the value to build the query - this works great. However, there's a large text input box which receives a number of extra conditions - this text box receives the input in the following format:
    searchAttributeName1,searchAttributeValue1;searchAttributeName2,searchAttributeValue2
    This is functional, however, it's a bit rubbish as the user has to know the special recognised attributeNames. What I would like to have is some sort of criteria control. This would consist of a drop down box populated from the servlet, a text input for the value and a button to add another criteria control. so the user could build up the number of query criteria. The drop down box ensures they cannot select the wrong keyword, pressing the add criteria button adds a new drop down box and text box pair to the screen.
    An example of this I recently saw was at Intel's jobs search web site https://jobs.intel.com/jobs/jobs.iccw - see that for example.
    Has anyone got any ideas on how to achieve this? I initially thought use jsp scripting (there is no restriction against this) but I need to use javascript I'm guessing as the button click triggers adding a new combo box. Another idea was to use styles and tables to hide the other drop down boxes but this seems like a real hack that I'd like to avoid. I can do with with .NET i hope java can deliver!
    Any ideas are much appreciated - I am a novice with java web development so please, any examples thoroughly explain (no need to explain populating the drop down box - there seem to be plenty of posts on this).
    Thanks for any help or ideas on this issue -

    Gina,
    Here is some sample code for using a ComboBox in a JSP from an EditCurrentRecord bean. This particular example uses a query, you can also populate combo boxes, list boxes, radio buttons and checkboxes from a static list. See the JavaDocs for the EditCurrentRecord bean.
    <jsp:useBean id="RowEditor" class="oracle.jbo.html.databeans.EditCurrentRecord" scope="request">
    <%
    RowEditor.initialize(application, session , request, response, out, "wt_bc_WT_bcModule.WalkthroughEngineSlidesView");
    RowEditor.setTargetUrl("WalkthroughEngineSlidesView_SubmitInsertForm.jsp");
    RowEditor.createNewRow();
    RowEditor.setReleaseApplicationResources(true);
    RowEditor.useComboBox("Presname","select pres_name,pres_name from wt_info","PRES_NAME","PRES_NAME");
    RowEditor.render();
    %>
    </jsp:useBean>
    null

  • Best practice on dynamically changing drop down in page fragment

    I have a search form, which is a page fragmant that is shared across many pages. This form allows users to selct a field from the drop down list, and search for a particular value, as seen in the screenshot here:
    http://photos1.blogger.com/blogger2/1291/174258525936074/1600/expanded.5.gif
    Please note that the search options are part of page fragmant embedded within a page - so that I can re-use it across many pages.
    The drop down list changes,based on the page this fragment is embedded. For users page, it will be last name, first name, etc. For parts page, it will be part number, part desc., etc.
    Here is my code:
              Iterator it=getTableRowGroup1().getTableColumnChildren();
            Option options[]=new Option[getTableRowGroup1().getColumnCount()];
            int i=0;
            while (it.hasNext()){
                TableColumn column=(TableColumn)it.next();
                if (column.getSort()!=null){
                    options=new Option(column.getSort().toString(), column.getHeaderText());
    }else{
    options[i]=new Option(column.getHeaderText(), column.getHeaderText());
    i++;
    search search=(search)getBean("search");
    search.getSearchDDFieldsDefaultOptions().setOptions(options);
    This code works, but it gives me all fields of the table available in the drop down. I want to be able to pick and choose. May be have an external properties file associated with each page, where I can list the fields available for search drop down??
    What is the best practice to load the list of options available for drop down on each page? (i.e last name, first name, etc.) I can have the code embedded in prerender of each page, or use sort of a resouce bundle for each page or may be use a bean?

    I have to agree with Pixlor and here's why:
    http://www.losingfight.com/blog/2006/08/11/the-sordid-tale-of-mm_menufw_menujs/
    and another:
    http://apptools.com/rants/menus.php
    Don't waste your time on them, you'll only end up pulling your hair out  :-)
    Nadia
    Adobe® Community Expert : Dreamweaver
    Unique CSS Templates |Tutorials |SEO Articles
    http://www.DreamweaverResources.com
    Book: Ultimate CSS Reference
    http://www.sitepoint.com/launch/005dfd4/3/133
    http://twitter.com/nadiap

  • Jsp / Servlet / bean / upload

    Hello,
    I use a jsp to enter several fields. These fields are sent to a servlet by using a bean (recorded in the current session). Until now there is no problem. The servlet receives all information. Now I must also send 5 files which must be stored on the server. I have thus to add in my jsp 5 file fields.
    My question :
    Is it possible to integrate the FileUpload package for uploader my files without anything to change in my code (by using of a bean to exchange the data between my jsp and my servlet). ??
    In other words, it is possible to use my bean to also transport files. ??
    Tank u for u help

    Yes it is possible..
    download cos.jar from www.oreily.com for file upload..
    it will read dat from the form as two parts ..
    parameter part and file part..
    and you can implement it throgh a servlet easily..
    for more follow oreily JSP/servlets Cookbook

  • Loading data in a drop down menu using jsp

    hello everyone...
    I'm very new to JSP programming....i'm facing a problem regarding loading the data in a drop down menu at the button click.....
    what i'm doing is...i'v taken a button and at the button click the data from "Sql Server 2000" shd load in a drop down menu....here's the code which i think will make my point clear....
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <%
              Connection con=null;
              ResultSet rs=null;
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   con=DriverManager.getConnection("jdbc:odbc:p_portal");
                   Statement stat=con.createStatement();
                   String sql="select * from message_box where name='anindo'";
                   rs=stat.executeQuery(sql);
                   %>
    <script language="javascript">
    function check()
         var show=document.getElementById("mydivtag");
         show.innerHTML = "<label><select name=select><% while(rs.next()){%><option><%= rs.getString(1) %></option><option><%= rs.getString(2) %></option><option><%= rs.getString(3).substring(0,10) %></option></select></label><%}}catch(Exception ex){out.print("Exception is:- "+ex);}%>";
    </script>
    </head>
    <body>
    <form id="form1" name="form1" method="post" action="">
      <label></label>
      <p>       
        <input type="submit" name="Submit" value="Submit" onclick="check()" />
           </p>
      <p>       
       </p>
      <div id="mydivtag" ></div>
      <p> </p>
    </form>
    </body>
    </html>

    yep Ajax is d right way 2 do so.
    So can use DWR(ajax tech.) for dis/
    To implement dis dere r simple steps u hav 2 follow
    1. entry for <dwr> tag in web.xml
    2. entry for <onverter>in web.xml
    3. In jsp u write
    <script type="text/javascript" src="<%=appName%>/dwr/engine.js"></script>
    <script type="text/javascript" src="<%=appName%>/dwr/util.js"></script>
    <script type="text/javascript"src="<%=appName%>/dwr/interface/ClassService.js"></script>
    were ClassService is ur class whose method u want 2 call.
    4.
    In jsp under <script> u can simply write
    ClassService.Methodname(param1,param2,....,CallBackFunction);
    5.CallBackFunction(data)
    /// do wt u want
    For more details u can find it on google.

  • Jsp-servlet-bean problem

    Please help!
    I have a servlet controller, a javabean for the data and a jsp for the view.
    I cannot get the jsp using
    <jsp:useBean id="pList" class="bbs.PostListCommand" scope="request" />
    to access the bean data
    However, when I access the bean in this way
    <%@ page import="bbs.PostListCommand" %>
    // html
    <% bbs.PostListCommand postList = null;
    synchronized(session){
         postList = (bbs.PostListCommand) session.getAttribute("PostListCommand");
         if (postList == null){ %>
              <H1>Nothing in request scope to retrieve ....</H1>
              <P>
    <%     }
         else{  %>
              <TABLE border="1">
    // etc
    � it works
    Does anyone know why the <jsp:useBean> tag does not find the bean
    I have installed tomcat 4.18 and set the environmental variables etc.
    Directory structure is
    E:\Tomcat41\webapps\examples\WEB-INF\jsp          for jsp�s
    E:\Tomcat41\webapps\examples\WEB-INF\classes\bbs     for bean and servlets
    Thanks in advance for any help.
    Chris

    GrayMan - Thanks for your help.
    Let me explain my problem in more detail ...
    Background:
    I have some servlet experience, but I am new to jsp - so sorry if this seems trivial to you ...
    I have a book called bitter java by bruce tate from manning.com . I am trying to get the chapter 3 examples to work
    There are three files
    PostListCommand          the bean
    PostListController     the servlet
    PostListResults          jsp
    And a new test file � PostListResults version 2 with scriptlet code to access the bean.
    There are a couple of typos in the downloaded source files, but nothing that causes the main problem of not being able to access the bean data.
    Program flow
    Servlet instantiates new bean
    Bean � gets data from db
    Servlet passes bean to jsp with a forward
    Jsp outputs data
    I have put the files in the directories �
    E:\Tomcat41\webapps\examples\WEB-INF\jsp          for jsp�s
    E:\Tomcat41\webapps\examples\WEB-INF\classes\bbs     for bean and servlets
    The complete source code for each file is given below.
    1 I have checked the db access � that�s ok
    2 I have also checked reading the bean data back in from the request scope and printing out the results from within the servlet.- ok
    3 I can access the data through a scriptlet (PostListResults version 2), but not with the original PostListResults which uses <jsp:useBean>
    thanks in advance, chris
    PostListController.java
    package bbs;
    // Imports
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    // Import for commands used by this class
    import bbs.PostListCommand;
    public class PostListController
    extends javax.servlet.http.HttpServlet
    implements Serializable {
    * DoGet
    * Pass get requests through to PerformTask
    public void doGet(
    HttpServletRequest request,
    HttpServletResponse response)
    throws javax.servlet.ServletException, java.io.IOException {
    performTask(request, response);
    public void performTask(
    HttpServletRequest request,
    HttpServletResponse response) {
    try {
    PostListCommand postList = (bbs.PostListCommand) java.beans.Beans.instantiate(getClass().getClassLoader(),"bbs.PostListCommand");
    postList.initialize();
    postList.execute();
    request.setAttribute("PostListCommand", postList);
    ServletContext sc = this.getServletContext();
    RequestDispatcher rd =
    sc.getRequestDispatcher("/jsp/PostListResults.jsp");
    rd.forward(request, response);
    } catch (Throwable theException) {
    theException.printStackTrace();
    PostListCommand.java
    package bbs;
    import java.io.*;
    import java.sql.*;
    //import COM.ibm.db2.jdbc.*;
    import java.util.*;
    * Insert the type's description here.
    * Creation date: (07/17/2001 5:07:55 PM)
    * @author: Administrator
    public class PostListCommand {
    // Field indexes for command properties     
    private static final int SUBJECT_COLUMN = 1;
    private static final int AUTHOR_COLUMN = 2;
    private static final int BOARD_COLUMN = 3;
    protected Vector author = new Vector();
    protected Vector subject = new Vector();
    protected Vector board = new Vector();
    // SQL result set
    protected ResultSet result;
    protected Connection connection = null;
    * execute
    * This is the work horse method for the command.
    * It will execute the query and get the result set.
    public void execute()
    throws
    java.lang.Exception,
    java.io.IOException {
    try {
    // retrieve data from the database
    Statement statement = connection.createStatement();
    result =
    statement.executeQuery("SELECT subject, author, board from posts");
    while (result.next()) {
    subject.addElement(result.getString(SUBJECT_COLUMN));
    author.addElement(result.getString(AUTHOR_COLUMN));
    board.addElement(result.getString(BOARD_COLUMN));
    result.close();
    statement.close();
    } catch (Throwable theException) {
    theException.printStackTrace();
    * getAuthor
    * This method will get the author property.
    * Since the SQL statement returns a result set,
    * we will index the result.
    public String getAuthor(int index)
    throws
    java.lang.IndexOutOfBoundsException,
    java.lang.ArrayIndexOutOfBoundsException {
    return (String) author.elementAt(index);
    * getBoard
    * This method will get the board property.
    * Since the SQL statement returns a result set,
    * we will index the result.
    public String getBoard(int index)
    throws
    java.lang.IndexOutOfBoundsException,
    java.lang.ArrayIndexOutOfBoundsException {
    return (String) board.elementAt(index);
    * getSubject
    * This method will get the subject property.
    * Since the SQL statement returns a result set,
    * we will index the result.
    public String getSubject(int index)
    throws
    java.lang.IndexOutOfBoundsException,
    java.lang.ArrayIndexOutOfBoundsException {
    return (String) subject.elementAt(index);
    * initialize
    * This method will connect to the database.
    public void initialize()
    throws java.io.IOException {
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
    // URL is jdbc:db2:dbname
    String url = "jdbc:db2:board";
    // URL is jdbc:odbc:bitter3board
    String url = "jdbc:odbc:bitter3board";
    // connect with default id/password
    connection = DriverManager.getConnection(url);
    } catch (Throwable theException) {
    theException.printStackTrace();
    * Insert the method's description here.
    * Creation date: (07/17/2001 11:38:44 PM)
    * @return int
    * @exception java.lang.IndexOutOfBoundsException The exception description.
    public int getSize() {
    return author.size();
    PostListResults.jsp
    <HTML>
    <HEAD>
    <TITLE>Message Board Posts</TITLE>
    </HEAD>
    <BODY BGCOLOR=#C0C0C0>
    <H1>All Messages</H1>
    <P>
    <jsp:useBean id="postList" class="bbs.PostListCommand" scope="request"></jsp:useBean>
    <TABLE border="1">
    <TR>
    <TD>Subject</TD>
    <TD>Author</TD>
    <TD>Board</TD>
    </TR>
    <% for (int i=0; i < postList.getSize(); _i++) { %>
    <TR> <TD><%=postList.getSubject(_i) %></TD>
    <TD><%=postList.getAuthor(_i) %></TD>
    <TD><%=postList.getBoard(_i) %></TD>
    </TR>
    <% } %>
    </TABLE>
    <P>
    </BODY>
    </HTML>
    PostListResults.jsp version 2 � with scriplet code instead of useBean
    <HTML>
    <%@ page import="bbs.PostListCommand" %>
    <!-- This file was generated by the chris -->
    <HEAD>
    <TITLE>Message Board Posts</TITLE>
    </HEAD>
    <BODY BGCOLOR=#C0C0C0>
    <% bbs.PostListCommand postList = null;
    synchronized(request){
         postList = (bbs.PostListCommand) request.getAttribute("PostListCommand");
         if (postList == null){ %>
              <H1>Nothing in request scope to retrieve ....</H1>
              <P>
    <%     }
         else{  %>
              <TABLE border="1">
              <TR>
              <TD>Subject</TD>
              <TD>Author</TD>
              <TD>Board</TD>
              </TR>
         <% for (int i=0; i < postList.getSize(); _i++) { %>
                   <TR> <TD><%=postList.getSubject(_i) %></TD>
              <TD><%=postList.getAuthor(_i) %></TD>
              <TD><%=postList.getBoard(_i) %></TD>
              </TR>
         <% } %>
              </TABLE>
    <%     }
    }%>
    <P>
    goodnight
    </BODY>
    </HTML>

  • Changing drop down list appearance

    I was wonder how I can add additional attributes to a drop down list. I would like to add a different color to each option in the box. Something similar to the following code:
    <style type="text/css">
    .bg1{background-color:FF0000}
    .bg2{background-color:00FF00}
    .bg3{background-color:0000FF}
    </style>
    <form action="" method="post">
    <select name="foo">
         <option class="bg1">red</option>
         <option class="bg2">green</option>
         <option class="bg3">blue</option>
    </select>
    </form>
    I can't seem to find were I can add this informaiton. Thank you in advance.

    sorry about that, thomas. maybe it'd help if i read your post more closely before responding. anyhow, i had to get carl's help for this, but here are two ways to implement your request...
    javascript approach: just drop in a jscript function that checks your option values and displays them as you'd like. so if you had a select list item, P2_DEPTNO, with an lov query like...
    select dname, deptno from dept
    ...you could place this javascript...
    <script language=JavaScript type=text/javascript>
    <!--
    var pThis = document.getElementById('P2_DEPTNO');
    var pThose = pThis.getElementsByTagName('OPTION');
    for(var i=0;i < pThose.length;i++){
    /*change this logic for colors*/
    if(pThose.value == "10"){
    pThose[i].style.background = "#00FF00";
    if(pThose[i].value == "20"){
    pThose[i].style.background = "#996633";
    if(pThose[i].value == "30"){
    pThose[i].style.background = "#0000FF";
    if(pThose[i].value == "40"){
    pThose[i].style.background = "#FF0000";
    //-->
    </script>
    ...in the "Post Element Text" field of the item-level attributes page of your item.
    style approach: i'm not a css pro, but if your users use browsers that are somewhat css compliant (not IE), you can use define a style like...
    <style type="text/css">
    <!-- .myColors{}
    .myColors > option{background-color:#336699;}
    .myColors > option+option{background-color:#FF0000;}
    .myColors > option+option+option{background-color:#FFFF00;}
    .myColors > option+option+option+option{background-color:#996633;}
    .myColors > option+option+option+option+option{background-color:#669933;}
    -->
    </style>
    ...also in that "Post Element Text" field (or in your CSS, of course) and drop a...
    class="myColors"
    ...into the "HTML Form Element Attributes" field on that same page.
    hope this helps,
    raj

  • Dynamic drop down list in jsp,javascript!!

    Hi,
    I want to generate dynamic drop list for country,state & city drop downs.Depends upon the country Id the states have to be list out & depends upon the state & country Id ,i have to get the cities.
    I am using jsp,servlets & javascript & my browser is Iceweseal.It should work in firefox & other browsers also.I want someone guidance for this.I can't use xmlHttp.
    so can any one tell the procedure & tel me the codings for this.
    Itz very urgent...
    Plz help me friends...

    I've answered this countless times before: [http://google.com/search?q=populate+dropdown+balusc+site:sun.com]
    One of the answers: [http://forums.sun.com/thread.jspa?threadID=5370149].

Maybe you are looking for