Dropdown list in jsp

Hi -
I need some help.Here is my problem. I am writing drop down list in the jsp. I need to get the value of dropdown list and submit the form and again calling same jsp page. So i didn't see the same value in the
dropdown list whichever i was submitting.its giving some javascript errors.I really appreciate if anyone resolves this problem or valuble suggestions.
<script language="JavaScript">
function messageValue(){
<%
String id = request.getParameter("id");
if (id != null)
%>
     document.myForm.id.value = <%=id%>
document.myForm.submit();
<%
else {
%>
var messageIndex = document.myForm.id.selectedIndex;
var selectedValue = document.myForm.id.options[messageIndex].value;
document.myForm.id.value = selectedValue;
document.myForm.submit();
<% } %>
</script>
<select name="id" onChange="messageValue()">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>

<script language="JavaScript">
function messageValue(){
var messageIndex = document.myForm.id.selectedIndex;
var selectedValue = document.myForm.id.options[messageIndex].value;
document.myForm.id.value = selectedValue;
document.myForm.submit();
</script>
<%
String id = request.getParameter("id");
if(id == null) id = "";
%>
<select name="id" onChange="messageValue()">
<option value="1" <%= id.equals("1") ? "selected" : "" %>>1</option>
<option value="2" <%= id.equals("2") ? "selected" : "" %>>2</option>
<option value="3" <%= id.equals("3") ? "selected" : "" %>>3</option>
</select>

Similar Messages

  • How 2 disply 2 or More coulmns from the DBase to Dropdown list in JSP

    Dear Friends,
    Please can anyone help us, on displaying the 2 or more columns into a single Dropdown list in the JSP page, by using Struts-tag Libraries
    We are displayig only 1 coulmn from the DBase resultset to Dropdown list,
    When we try to concatenate, 2 columns of the resulset, the data format has changed
    Please help, Early response is appreciated
    Thanking you
    Jagadish

    WE are using sturts , Fallowing is code for
    extracting the O_NOUN and O_MODIFIER table Columns from the DBase and setting into
    "mat_Reg_ActionForm" form
         Statement stmt = null;
         ResultSet rs = null;
         ArrayList objQualList = new ArrayList();
         String query = " SELECT UNIQUE O_NOUN , O_MODIFIER FROM O_NOUN_MOD ";     
         stmt = conn.createStatement();
    rs = stmt.executeQuery(query);
         String columnLabel = (rsmd.getColumnName(0)+"|"+rsmd.getColumnName(1));
         String columnLabel = "Object"+"|"+"Modifier";
         objQualList.add(columnLabel);
         while(rs.next())
         String objModifier = (rs.getString("O_NOUN")+"|"+rs.getString("O_MODIFIER"));     
         objQualList.add(objModifier);
         mat_Reg_ActionForm.setObject(objQualList);
    Fallowing the iteration with which we are displaying the data in the Drop downl List
    "mat_Reg.jsp"
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <html>
    <head><title></title>
    </head>
    <body>
    <html:form action="mat_Reg.do" name="mat_Reg_ActionForm" type="com.pilog.bo.ManfPartNoActionForm">
         <html:select name="mat_Reg_ActionForm" property="object">
              <html:options name="mat_Reg_ActionForm" property="object"/>
         </html:select>
    </TR>
    </TABLE>
    </html:form>
    </body>
    </html>
    Is this code will help you give us some guidence ! Your early reply will be appreciated
    Thankng you

  • How to retrieve datas from database to dropdown list in jsp

    hai.
    please tell me how to retrieve a perticular field list from database to a drop down list using jsp. i am new to jsp. i am doing employee management system. in that i need to edit employee's details as like.
    so that i want to display employee id's in a drop down list. i want to retrieve from database and display.
    please help me in this .
    advance thanks.

    Hello friendz,
    If tht is the i wud suggest if guyz can go wid AJAX...
    try to make use of xmlHttp Object and generate a new dependent drop down by using a property from a bean->servlet->VIEW(FORM)
    else save the form state in a session and then refersh it. once all in again.
    i had a similar problem which i solved in the following way
    Hi friend,
    I had a similar situation and i tried to solve it by using XmlHttpRequest Object(used in AJAX).
    U can checkout the below example just for further reference delete
    UserForm.jsp:
    ==========
    <head>
    <script>
    var xmlHttp
    function showState(str)
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    alert ("Browser does not support HTTP Request")
    return
    var url="getState.jsp"
    url=url+"?count="+str
    url=url+"&sid="+Math.random()
    xmlHttp.onreadystatechange=stateChange
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
    function stateChange()
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
    document.getElementById("state").innerHTML=xmlHttp.responseText
    </head>
    <body>
    <select name='country' onchange="showState(this.value)">
    <option value='india>india</option>
    </select>
    <br>
    <div id='state'>
    <select name='state' >
    <option value='-1'>pickone</option>
    </select>
    </div>
    </body>       
    getState.jsp
    ============
    <%@page language="java" import ="java.util.Hashtable" import ="java.util.Set" %>
    <%
    String country=request.getParameter("count");
    response.setContentType("text/html");
    response.setHeader("Cache-Control","no-cache");
    try{
    Hashtable ht = (Hashtable)session.getAttribute("<ATTRIBUTE_NAME>");
    String buffer="<select name='state'><option value='-1'>Pick One</option>";
    Set s=ht.keySet();
    Object keys[]=s.toArray();
    int size=keys.length;
    for(int i=0; i < size;i++){
    buffer=buffer+"<option value='"+ht.get(keys).toString()+"'>"+ht.get(keys).toString()+"</option>";
    buffer=buffer+"</select>";
    response.getWriter().println(buffer);
    catch(Exception exp){
    response.getWriter().println(exp);
    %>

  • Dynaic Dropdown list in JSP

    Hi all,
    I have a web application in JSP and Tomcat, Microsoft Access is used as a database. On my application I have a dynamic drop down list which geneates all our client list from database. The reason why I am calling it dynamic is because the user can generate as many drop down list as they want based on their need so that they can record their time spent with those client.
    Now the users are demanding that they want the web application to remember the clients they have selected last time they logged in which could be 7 or 10 drop down list with the client selected from the list. Now how can put this into programming? Can I use javascript to do that or JSP? Or do I need to use cookies. Can anyone suggest me how to use cookies.
    Thanks

    you can do it via JSP: you store users selections in the database (pesistent cach) and reuse them when needed but this is complex and needs more db space.
    you can also do this using cookies. see some examples here http://www.javascriptkit.com/script/cutindex7.shtml

  • How to create a JSP dropdown list in the latest Early release

    Hello:
    this is probably an easy question. I am trying to create a dropdown list in a JSP form from a data control like "employee id". just dragging the data control attribute does not seem to have any effect in showing the drop down list when the JSP page is run.
    What is the missing factor?
    Thanks in advance for the help.

    Please ask this in the JHeadstart forum
    Timo

  • Changing dropdown list selected value in JSP

    I would like a dropdown list to load with all values in a database table, which is no problem. But, I would then like it to display a selected text value from that list, depending on the value returned by a SQL query. As an example, say I was looking-up someone's personal data and there was a dropdown list that listed all the possible hair colors. If this person had been entered as having blonde hair, I want the dropdown list to display blonde at page load, but give the user the option to select another color if a change is needed.
    Thanks in advance for ur help.

    <option value="<c:out value="${currentchoice}"/>"
        <c:if test="${currentchoice=='db_value'}">     
            SELECTED 
        </c:if>
    >

  • Not All Items Appearing In Dropdown List

    Hi,
    You have a newbie here. I am trying to populate a dropdown list in a JSP with the following code, but not all the records are being displayed (approximately 4900 records are displayed). The Submit button that follows this Select tag is not being displayed, nor are any error messages being encountered. The last Option tag is incomplete. Any clues?
    Thanks,
    Neil.
    +{color:#0000ff}Vendor: <select name="gsdb">+
    +<% String vGSDB = null;+
    String vName = null;
    String GSDB = null;
    +if(request.getParameter("gsdb") == null){+
    GSDB = "";
    +}else{+
    GSDB = request.getParameter("gsdb").toString().substring(0,5);
    +}+
    i = 0;
    +while(i < vendorName.length) {+
    +if (vendorName == null) {+
    break;
    +}+
    vGSDB = vendorName.substring(0,5);
    vName = vendorName.substring(6);
    +if(vGSDB.equalsIgnoreCase(GSDB)) {+
    out.println("<option value=\"" vGSDB + "\"selected>" + vName + " **" + vGSDB + "**</option>+
    +");+
    +}else{+
    +out.println("<option value=\"" + vGSDB + "\">" + vName + " **" + vGSDB + "**</option>+
    +");+
    +}+
    +i++;+
    +}+
    +%>+
    +</select>{color}+

    You have 4900+ records?? I'd say there was some exception being thrown somewhere, either you're running out of memory or something. Your response isn't coming completely which indicates that your output was interrupted but since it had been committed, the server couldn't redirect to an error page or display the exception or stack trace.
    Check your logs, there'll definitely be something there.

  • Is it possible? two dropdown list

    I try to get a value from the first dropdown(jdbc connection) in the second dropdown box.
    using jdeveloper 10.1.3.4
    I always get error message;
    500 Internal Server Error
    java.lang.NullPointerException     at hr.DataHandler.get_prj_num(DataHandler.java:446)     at _test__dropdown._jspService(_test__dropdown.java:68)     [/test_dropdown.jsp]     at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.4.0) ].http.OrionHttpJspPage.service(OrionHttpJspPage.javaI think request.getParameter() in second dropdown box can not read it from the first dropdown box.
    would you help me ? - code is the following, not everything because of space-
    ****datahandler class****
        public ResultSet get_prj_num(String job_title) throws SQLException {
          try {
            job_title = job_title.toUpperCase();
            getDBConnection();
            String jobquery = "begin ? := get_prj_num(String job_title); end;";
            CallableStatement callStmt = conn.prepareCall(jobquery);
            callStmt.registerOutParameter(1, OracleTypes.CURSOR);
            callStmt.execute();
            rset = (ResultSet)callStmt.getObject(1);
          } catch ( SQLException ex ) {
          logException( ex );
          return rset;
    ***function in database***
    FUNCTION GET_PRJ_NUM(st in VARCHAR2)
    RETURN PRJPKG_NUM.REF_CURSOR
    AS PRJNUM_CURSOR PRJPKG_NUM.REF_CURSOR;
    BEGIN
    OPEN PRJNUM_CURSOR FOR
    SELECT PROJECT_NUMBER FROM PROJECTS WHERE STATE_CODE =st;
    RETURN PRJNUM_CURSOR;
    END;
    ****jsp page a part of it -for space*****
    <%@ page language="java" import=" java.sql.ResultSet"%>
          <jsp:useBean id="empsbean" class="hr.DataHandler" scope="session"/>
           <%ResultSet rset = empsbean.get_prj();%>
        </h3><form action="insert_action.jsp ">
          <table cellspacing="2" cellpadding="3" border="1" width="70%">
            <tr>
              <td width="30%">
                <span class="bold">
                  <span class="bold">
                    <span class="bold">
                      <span class="bold">
                        JOB_TITLE
                      </span>
                    </span>
                  </span>
                </span>
              </td>
              <td width="70%">
                <select size="1" name="JOB_TITLE">
                  <%while (rset.next ())
        out.println("<option value=" + rset.getString("state_code") + ">" +
        rset.getString("state_code") + "</option> "  );
    empsbean.closeAll();
    %>
                </select>
              </td>
            </tr>
            <tr>
              <td width="30%">
                <span class="bold">
                  <span class="bold">
                    <span class="bold">
                      <span class="bold">
                        STATUS
                      </span>
                    </span>
                  </span>
                </span>
              </td>
              <td width="70%">
                <select size="1" name="prjnum_drop">
    <%ResultSet rset1;
    String job_title = request.getParameter("JOB_TITLE");
    // String job_title ="TN";
      rset1 = empsbean.get_prj_num(job_title);
    %>
                  <%while (rset1.next ())
        out.println("<option value=" + rset1.getString("project_number") + ">" +
        rset1.getString("project_number") + "</option> "  );
    empsbean.closeAll();%>Edited by: Jin on Oct 10, 2008 2:51 PM

    after debugging, I have one error now.
    500 Internal Server Error
    java.lang.NullPointerException     at _test__dropdown._jspService(_test__dropdown.java:70)     [/test_dropdown.jsp]     at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.4.0) ].http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)     at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)     at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)     at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.4.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.4.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.4.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.4.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.4.0) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.4.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.4.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)     at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)     at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:234)     at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:29)     at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:879)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.4.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:298)     at java.lang.Thread.run(Thread.java:595)java.lang.NullPointerException     at test_dropdown._jspService(_test__dropdown.java:70)-the error points at the following;
    String job_title = request.getParameter("JOB_TITLE");
    it seems the second dropdown couldn't get the value from the first dropdown selection.
    I wonder jdbc connection in the first dropdown still alive when the second dropdown list turns.
    is it easy to use Servlet with the two dependent dropdown list?
    thanks

  • Split Values in a dropdown list

    Hi friends
    i am stuck with a problem for which i need your help.i will list it out as below.
    i am having a dropdown in my jsp page a ComboBox. The values in the dropdown are in the form
    After 10 minutes
    After 20 minutes
    After 30 minutes
    Before 5 minutes
    Now when the user selects a value in the dropdown list ex. After 10 minutes. This value needs to be fetched and i have to retrive 10 & minutes seperately from the string "After 10 minutes" and the values should go into two different colums of 2 tables in the database.
    I cannot use a DTO to set these values since the values will be combination pair of value & timetype.
    What should be my approach here.
    should i use a Hashmap or a Hashtable or some list so that i can send these values from the Action class to the Session Bean method.
    please let me know what needs to be done in this case.waiting for a positive reply from your side.
    Thanks & Regards
    Vikram K

    Create your own object which can store the different values and override the toString() method to display "After 10 Minutes" etc.
    i.e.
    private class MyClass {
       private int unit;
       private String measurement;
       public MyClass {
          super();
       // Getter and Setter Methods for fields
       public String toString() {
          return "After " + unit + " " + measurement;
    }Then you can create a custom ComboBoxModel that contains your list of custom objects. Then it's a simple case of adding an ActionListener to the ComboBox to see which object the User has selected so you can then use the getter methods to pull the info you need and populate your table.

  • Blank line in DropDown List box

    I have a case where I want to add a blank entry in a drop down list box that is bound to a database table. I want the blank to be the default, then the user can select the bound values if desired. How do I do this without binding the drop down box to a prepopulated array?

    Hi
    Go to the JSP source of that page and add
    <f:selectItem itemLabel="None" itemValue="0"/> before
    the line <f:selectItems binding="#{Page1.dropdown1SelectItems}" ....
    With this you can deselect the previous selection by selecting None from the dropdown list. You can also use blank spaces instead of None.
    Thanks
    Srinivas

  • Displaying a list in JSP

    Hi guys,
    I'm struggling to find any examples of how to display a list of data in a custom JSP page. I will have some type of holding object to contain an array of BPM Objects. I would like to display one table row in the JSP for each object.
    Does anyone have any examples of what format the instance variable should be and how i can map this into the attributes and iterate over this in the JSP.
    thanks!
    Neil

    Here is some js code that calls the method 'getByRegion' on the myInfo view object, that I had passed into the jsp. Here is an example of how to populate a Dropdown list in the jsp, with the returned values... Its not on the same line as what you wanted, but will give you an example of using ajax to call a bpm method.
    function regionSelect(regionValue){
         var sel = document.getElementById("entity");
         sel.options.length=0;
         var myurl = '<f:invokeUrl var="myInfo" methodName="getByRegion"/>';
              $.get(myurl, {name: regionValue}, function(data){
                   for(i=0; i<data.length;i++){
                        sel.options=new Option(data[i].key + ' - ' + data[i].value,data[i].key, false, false);
              }, "json");
    And the BPM Method code:  Note, its returning a JSON string here.
    This takes a java.util.map (requestParams) as an input argument.inAr as String[] = String[](get(requestParams, arg1 : "name"))
    inVal as String = toLowerCase(inAr[0])
    entity as String[]
    entityId as String[]
    sql as String = "select ENTITY_ID, ENTITY_DESC from vm_opts_coun_reg_entity where region = '" + toUpperCase(inVal) + "' order by entity_id"
    for each row in executeQuery(DynamicSQL, sentence : sql, implname : "AppDB") do
         entity[] = String(row["ENTITY_DESC"])
         entityId[] = String(row["ENTITY_ID"])               
    end
    retString as String = "["
    for i in 0..length(entityId)-1 do
         key as String = entityId[i]
         value as String = entity[i]
         retString = retString + "{\"value\" : \"" + value + "\",\"key\" : \"" + key + "\" },"
    end
    if length(retString) > 1 then
         retString = substring(retString, first : 0, last : length(retString)-1)
    end
    retString = retString + "]"
    return retString
    HTH!
    -Kevin                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Adding values to dropdown list programmatically

    Hi, all
    I have an arrayList as a set of choices for a dropdown list. how do i add it to the dropdown list programmatically?
    thanx

    this is what i'm trying to do: but there's error..
    FacesContext fc = FacesContext.getCurrentInstance();
              UIViewRoot uiv = fc.getViewRoot();
              Application application = fc.getApplication();
              String oldValue = (String)valueChangedEvent.getOldValue();
              String newValue = (String)valueChangedEvent.getNewValue();
              if(getMenu2() != null)
                   getMenu2().setRendered(true);
                   UISelectItems items = (UISelectItems) fc.getApplication().createComponent(UISelectItems.COMPONENT_TYPE);
                   items.setRendered(true);
                   items.setValue(getBxDataMrgBean().getAlist());
                   getMenu2().getChildren().add(items);
    javax.servlet.ServletException: javax.servlet.jsp.JspException: null
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:821)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
         org.apache.jsp.Local.inputEC_jsp._jspService(inputEC_jsp.java:106)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         com.ibm.faces.context.MultipartExternalContextImpl.dispatch(MultipartExternalContextImpl.java:320)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:295)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         com.hgst.plm.BomExtract.action.AuthenFilter.doFilter(AuthenFilter.java:49)
    root cause
    java.lang.ClassCastException
         com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber(MenuRenderer.java:508)
         com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:470)
         com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:428)
         javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:726)
         javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:604)
         javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:527)
         com.sun.faces.taglib.html_basic.SelectOneMenuTag.doEndTag(SelectOneMenuTag.java:473)
         org.apache.jsp.Local.inputEC_jsp._jspx_meth_h_selectOneMenu_1(inputEC_jsp.java:268)
         org.apache.jsp.Local.inputEC_jsp._jspx_meth_h_form_0(inputEC_jsp.java:188)
         org.apache.jsp.Local.inputEC_jsp._jspx_meth_hx_scriptCollector_0(inputEC_jsp.java:160)
         org.apache.jsp.Local.inputEC_jsp._jspx_meth_f_view_0(inputEC_jsp.java:131)
         org.apache.jsp.Local.inputEC_jsp._jspService(inputEC_jsp.java:97)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         com.ibm.faces.context.MultipartExternalContextImpl.dispatch(MultipartExternalContextImpl.java:320)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:295)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         com.hgst.plm.BomExtract.action.AuthenFilter.doFilter(AuthenFilter.java:49)

  • Visual JSf: textField hide or disable, when selecting dropDown list

    Hello everyone,
    I am new to this forum, I am working on Visaul JSF, I have a question,
    When i select a value dropDown List, i want to disable or hide textField depending on the selected item in the list.
    I have put javascript for dropDown list. I am not able to do this. Can any one help me please...
    <webuijsf:script>
                        function fun(sel){
                            var state = sel.options[sel.selectedIndex].value;
                            alert(state);
                            if(state == 2){ alert("if");  document.getElementById('form1:textField2').disabled='true' }else{ alert("else"); document.getElementById('form1:textField2').disabled='false'}
                    </webuijsf:script>for downdown, i have added this..
    onChange="fun(this)"In dropdon list
    name value
    One 1
    Two 2
    Three 3
    Jsp code:
    <jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
        <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
        <f:view>
            <webuijsf:page id="page1">
                <webuijsf:html id="html1">
                    <webuijsf:script/>
                    <webuijsf:script>
                        function fun(sel){
                            var state = sel.options[sel.selectedIndex].value * 1;
                            alert(state);
                            if(state == 2){ alert("if");  document.getElementById('form1:textField2').disabled='true' }else{ alert("else"); document.getElementById('form1:textField2').disabled='false'}
                    </webuijsf:script>
                    <webuijsf:head id="head1">
                        <webuijsf:link id="link1" url="/resources/stylesheet.css"/>
                    </webuijsf:head>
                    <webuijsf:body id="body1" style="-rave-layout: grid">
                        <webuijsf:form id="form1">
                            <webuijsf:textField id="textField2" onChange="" style="height: 18px; left: 174px; top: 258px; position: absolute; width: 216px"/>
                            <webuijsf:button id="button1" onClick="return fun()" style="position: absolute; left: 228px; top: 324px" text="Button"/>
                            <webuijsf:dropDown id="dropDown1" items="#{Page3.dropDown1DefaultOptions.options}" style="position: absolute; left: 312px; top: 90px" onChange="fun(this)"/>
                        </webuijsf:form>
                    </webuijsf:body>
                </webuijsf:html>
            </webuijsf:page>
        </f:view>
    </jsp:root>Thanks in advance
    Neha
    Edited by: Neha_540 on Apr 5, 2009 11:02 PM
    Edited by: Neha_540 on Apr 5, 2009 11:05 PM

    Hi Neha,
    Hope this helps.
    function changeMarital()
                                var marital = document.getElementById('form1:drpMarital_list').value;
                                if(marital == "Others")
                                    document.getElementById('form1:lblOtherMarital').style.display='';
                                    document.getElementById('form1:txtOtherMarital').style.display='';
                                else
                                    document.getElementById('form1:lblOtherMarital').style.display='none';
                                    document.getElementById('form1:txtOtherMarital').style.display='none';
                            }

  • Problem with dynamically loading the dropdown list from database

    Please help me,
    i am having a jsp page which contains a form
    with a textfield ,two dropdown list
    and a submit button
    when i select a list from first drop down, second drop down has to
    be loaded from the database dynamically according to the
    selected one in the first drop down.
    i gave onselect event for the first drop down and
    gave this one
    temp=first dropdown selected value
    self.location='currentfile+query='+temp;
    after this current page is reloading, but the already existing
    values in textfield and first selected value in drop down list is
    missing.
    how to solve this problem? and the rest of the problem. i mean
    loading the data into second drop down list.
    plz help me......

    in first <selcet> tag write Onchange and submit to the jsp then the values will return in second select box.

  • Dropdown list from the recursive table in DB2

    Hi
    I need to create a dropdown list that looks like this in my JSP:
    Root
    BaseChildA
    ChildB
    ChildC
    BaseChildD
    ChildE
    ChildF
    I have to create it from the recursive table in the database, with columns that show parent-child relationships like this:
    child parent
    root
    A root
    B A
    C A
    D root
    E D
    F E
    Does anyone have an algorithm for doing this?
    Thanks!!

    I assume you just need to get the data and don't need instruction on how to create a dropdown list. (If you do need that instruction, go look for an HTML site -- there are lots.) Anyway, aren't you just going to get all the data from the "child" column? That would be the easiest way to get the data. But if you need to get the data in the order you showed there, look into whether your database can have a query that gives that. It's often called a "bill of materials explosion" or something like that.

Maybe you are looking for

  • Itunes cannot see iPad2

    This is driving me Nuts!! I bought an iPad last year, and loved it for the 8 Hours I had it, then gave it as a Gift totthe Child in an attempt to stop him destroying computers! It worked, no more busted computers & laptops, bith PC & Mac!! So I thoug

  • Got an error message "You can't open the application iMovie because it may be damaged or incomplete"  What do I do next to try to fix?  Thanks.

    I tried accessing imovie after not using it for a long time and got an error message "You can't open the application iMovie because it is damaged or incomplete. I'm not sure how to go about addressing it.  Your suggestions would be very much apprecai

  • Using my USA 17" intel mac in Japan?

    Hello everyone. I was wondering if anyone had any experience with bringing an US purchased intelmac up to Japan. I've read some forums saying that I don't need a converter. Some people and sites say that Japan's plugs are equal size holes (versus one

  • How to use Connection.clientinfo with v$session table

    Hi everyone, I'm trying to keep tabs on the number of connections I create (via python and cx_Oracle) by monitoring Oracle's v$session table. From the cx_Oracle docs, it appears the preferred way to write my "module" and "action" parameters to v$sess

  • Why can't we have simple pro rata billing?

    I've been a BT Broadband customer for ten years, and I am sick of these sales packages with their prefabricated bandwidth allowances and telephone or TV options. It seems to me that the BT Broadband sales strategists have a philosophy more appropriat