in Education by
I have a jsp with two drop down location and department. The value of department dropdown is populated based on the value of location through Ajax. But when I try to save the page I can't access the value of department dropdown if the first item from the department drop down is selected. But if 2nd or 3rd item is selected it can be accessed from the servlet.
Division <% LocationPolulate lp = new LocationPolulate(); int Div_Id = lp.DivisionId(); %>
Location Name
Department Name
Division ID />
Division Name
  
Servlet protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); int intLocId = Integer.parseInt(request.getParameter("locName")); String strDivNm = (String) request.getParameter("divName"); int intDeptId = Integer.parseInt(request.getParameter("ddDeptName")); LocationPolulate lp = new LocationPolulate(); int Res = lp.InsertDivision(strDivNm, intLocId, intDeptId); if (Res == 0) { request.setAttribute("Errmsg", "Error Cannot Save Division"); RequestDispatcher dis1 = getServletContext().getRequestDispatcher("/AddDivision"); dis1.forward(request, response); } else { int Div = lp.DivisionId(); request.setAttribute("succmsg", "Successfully saved Division with division id:" + Div); RequestDispatcher dis1 = getServletContext().getRequestDispatcher("AddDivision.jsp"); dis1.forward(request, response); } } Any ideas? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
sorry for adding code as a part off comment...i could not fit the whole code so i had to add the comment..there was a mistake in the java script.the correct one is given below.Thanks all for your suggestion ... function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { var showdata = xmlHttp.responseText; var strar = showdata.split(":"); if(strar.length==1) { document.getElementById("locName").focus(); alert("Please Select location Id"); } else if(strar.length>1) { option=new Option("---Select---", -1); document.crtdocfrm.ddDeptName.options[0]=option; for(var i=1;i<strar.length-1;i=i+2) { option=new Option(strar[i+1], strar[i]); document.crtdocfrm.ddDeptName.options[(i-1)/2+1]=option; } } } } i am getting the id and name in the same string from another jsp and spliting it to get the value of the different department id and name.

Related questions

0 votes
    I want to put a value from database because my dropdown already have a value the same as the text ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 30, 2022 in Education by JackTerrance
0 votes
    I have an Enum package com.javarnd.bbms.enums; public enum BloodTypeEnum { A_PLUS(1, "A+"), ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    I'm using Semantic-UI-React in my React/Rails project and trying to use a Form.Select drop down ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    I'm using Semantic-UI-React in my React/Rails project and trying to use a Form.Select drop down ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    Greetings! I have a DropDownList within a FormView which are bound to XmlDataSources: In the page's ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Greetings! I have a DropDownList within a FormView which are bound to XmlDataSources: In the page's ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I'm having a small issue with setting the initial value of a dropdown. The code below is the view ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    This is a Dropdown control where I am binding the data, after bind I am putting the select statement. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I've following two path path1- test/hello/hello.php path2- test/hello1/hello1.php //notice the one ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    I've following two path path1- test/hello/hello.php path2- test/hello1/hello1.php //notice the one ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I'm trying to use the Power BI REST API, using an access token acquired with the "client credentials" method, ... What am I missing? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I have a HDInsight Hadoop cluster (Linux, deployed separately) on Azure VNet (restricting client IPs using NSG). ... Data Factory? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    I have three components - app, sideNav and wallForm. In the app header, I have a button that ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 10, 2022 in Education by JackTerrance
0 votes
    Does anyone know of a good tool for debugging JSPs from within Eclipse? I'd like to be able to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    Which tag should be used to pass information from JSP to included JSP? (a) Using tag (b) Using tag (c) Using ... , JSP & API of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
...