fetch database value to text box based on selected value my code given below pls correct my code

fetch database value to text box based on selected value my code given below pls correct my code

my Code Given below Pls... help me send correct code for me

jsp file...

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@ 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:html>
<head>
    <html:base/>
    <title>Login page</title>

</head>
<body onload ="getDestArray()">
<html:form action="/dedit" >
<center><table border="1">
        <tbody>
            <tr>
                <td>Destination : </td>
                <td>
                <html:select property="destination" onchange="getPrice()">
                <html:option value="0">?SELECT?</html:option>
                <html:options collection="menuList" property="destination"  />
                </html:select>
                </td>


            </tr>
            <tr>
                <td>Amount   : </td>
                <td id="price"><input type="text" value =" " property= "amount" id='pricecheck'/>
    <html:text value="" property="amount"/></td>
            </tr>
            <tr>
                <td colspan="2" valign="center"><html:submit value="Submit"/></td></tr>
        </tbody>
    </table></center>
</html:form>
</body>
</html:html>

<script>
var destArray=new Array();
function getDestArray(){
<logic:notEmpty name="form" property="arrPriceLis">
  <logic:iterate name="form" property="arrPriceLis" id="priceList ">

   destArray ["<bean:write name= 'priceList' property='destination'/>"] = "<bean:write name= 'pricelist'  property= 'priceList' />";
  </logic:iterate>
</logic:notEmpty>

}

function getPrice(){

var test =<bean:write name="menuBeanList" property="destArray"></bean:write>
//var test = document.forms[0].destination.value;
var price = destArray ["test"];
// try these stuff any one
document.forms[0].amount.value = price;
// else try this if its input tag
//document.getElementById('pricecheck').value= price;
// else IF ITS HYML TAG 
//document.getElementById('price').innerHTML = PRICE

}
</script>

Action class
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fetch;

import java.sql.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import fetch.MenuBean;



public class MenuAction extends Action {
    private final static String SUCCESS = "success";
    public ActionForward execute(ActionMapping mapping, ActionForm  actionform,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

         ArrayList menuList = new ArrayList();

        ArrayList menuBeanList = new ArrayList();

        MenuBean menu = null;
       MenuCombo menucombo = null;
    MenuForm form = new MenuForm();

        HttpSession session = request.getSession();
                session.setAttribute( "menuList", menuList);


// ELSE DO THIS 
    //MenuForm form = (MenuForm)actionform;
// thtas is to cascate  ur form

        try
        {

            Class.forName("oracle.jdbc.driver.OracleDriver");
           Connection                 con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","thiru","thirumal");
           PreparedStatement stmt=con.prepareStatement("select * from destination");
           ResultSet rs=stmt.executeQuery();

           while(rs.next())
            {
    menucombo=new MenuCombo();
    menu = new MenuBean();
                String destination = rs.getString(1);
      String destinationId = rs.getString(1);
     String price = rs.getString(2);
               menucombo.setDestination(destination);
    menucombo.setDestinationId(destinationId );
    menu.setDestination(destination );
    menu.setPrice(price );


    menuList.add(menucombo);
             menuBeanList.add(menu);

             }

    form.setArrPriceList(menuBeanList);
            form.setMenuList(menuList);

        }
        catch(Exception e)
        {

        }
        return mapping.findForward(SUCCESS);
    }
}

bean class
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fetch;

/**
 *
 * @author Thiru
 */
public class MenuBean {


private String destination;
private String price;

    public String getDestination() {
        return destination;
    }

    public void setDestination(String destination) {
        this.destination = destination;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

}
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

java class
package fetch;

/**
 *
 */
public class MenuCombo {


private String destination ;
private String destinationId;

    public String getDestination() {
        return destination;
    }

    public void setDestination(String destination) {
        this.destination = destination;
    }

    public String getDestinationId() {
        return destinationId;
    }

    public void setDestinationId(String destinationId) {
        this.destinationId = destinationId;
    }
}

DAO class

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fetch;

/**
 *
 * @author Thiru
 */
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.sql.*;
import java.util.ArrayList;
import fetch.MenuBean;

public class MenuData {



    public MenuData() {

    }
    public ArrayList menuList() {



        ArrayList menuList = new ArrayList();

        ArrayList menuBeanList = new ArrayList();

        MenuBean menu = null;
     MenuCombo menucombo = null;

        try
        {
            Class.forName("oracle.jdbc.driver.OracleDriver");
           Connection           con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","thiru","thirumal");
           PreparedStatement stmt=con.prepareStatement("select * from destination");
           ResultSet rs=stmt.executeQuery();

           while(rs.next())
            {
    menucombo=new MenuCombo();
    menu = new MenuBean();
                String destination = rs.getString(1);
      String destinationId = rs.getString(1);
     String price = rs.getString(2);
               menucombo.setDestination(destination);
    menucombo.setDestinationId(destinationId );
    menu.setDestination(destination );
    menu.setPrice(price );


    menuList.add(menucombo);
             menuBeanList.add(menu);

             }



        }
        catch(Exception e)
        {

        }

      return menuList;
    }

}

list getter and setter
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fetch;

import java.util.*;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author Thiru
 */
public class MenuForm extends org.apache.struts.action.ActionForm {

private ArrayList arrPriceList;
private String amount;
private String destination;
private ArrayList menuList;

    public String getAmount() {
        return amount;
    }

    public void setAmount(String amount) {
        this.amount = amount;
    }

    public ArrayList getArrPriceList() {
        return arrPriceList;
    }

    public void setArrPriceList(ArrayList arrPriceList) {
        this.arrPriceList = arrPriceList;
    }

    public String getDestination() {
        return destination;
    }

    public void setDestination(String destination) {
        this.destination = destination;
    }

    public ArrayList getMenuList() {
        return menuList;
    }

    public void setMenuList(ArrayList menuList) {
        this.menuList = menuList;
    }

}

thank U

View Answers









Related Tutorials/Questions & Answers:
fetch database value to text box based on selected value my code given below pls correct my code
fetch database value to text box based on selected value my code given below pls correct my code  my Code Given below Pls... help me send correct code for me jsp file... <%@page contentType="text/html" pageEncoding
fetch database value to text box based on selected value my code given below pls correct my code
fetch database value to text box based on selected value my code given below pls correct my code  my Code Given below Pls... help me send correct code for me jsp file... <%@page contentType="text/html" pageEncoding
Advertisements
jsp login code when username , password and dropdown box value is correct...
jsp login code when username , password and dropdown box value is correct...  my project has login in whic i should select the company name... value(i.e)company name should match.... pls provide code.... thanx   
jsp login code when username , password and dropdown box value is correct...
jsp login code when username , password and dropdown box value is correct...  my project has login in which i should select the company name... value(i.e)company name should match.... pls provide code.... thanx   1
pls review my code - Struts
pls review my code  Hello friends, This is the code in struts. when i click on the submit button. It is showing the blank page. Pls respond soon... misk which is created in oracle database
Pls review my code - Struts
Pls review my code  Hello friends, this is my code in struts action class this page contains checkboxes and radiobuttons also. when i enter the submit it shows me blank page. can anybody solve my problem its urgent. help me
pls review my code - Struts
pls review my code  When i click on the submit page i am getting a blank page Pls help me. thanks in advance. public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request
jsp code for a drop down box to retrive value from database
jsp code for a drop down box to retrive value from database  my project needs to get the value from database in to the drop down box..... pls give me code for that ..... tan q   1)login.jsp: <html> <script>
I am not able to display the selected value of my combobox
I am not able to display the selected value of my combobox   <?php echo "<select name=\"hello\">\n"; echo "<option value=\"NULL\">...; $select='<select size=1 name="unitcode">'; while($arrayRow = mysql_fetch
pls send code
pls send code   pls send code for set database value into text box based on selected value in struts and jsp   use any database and get its code for getting values from google
retrieve the data to text fields from database on clicking the value of combo box
retrieve the data to text fields from database on clicking the value of combo box   retrieve the data to text fields from database on clicking the value of combo box . I am not getting it plz help me out .   hi
code for insert the value from jsp to access database
code for insert the value from jsp to access database  code for insert the value from jsp to access database
Code to store SubCombo box value - Development process
Code to store SubCombo box value   Hi ,In the following code i want to store SubCombo box name instead of value for Department Field. Add Data var arr = new Array(); arr["Select"] = new Array("-select-"); arr["Dkn
my table should be reseted to new value upon the selection of the combo box..
my table should be reseted to new value upon the selection of the combo box... the constructor to initialize the form. * WARNING: Do NOT modify this code.... */ // <editor-fold defaultstate="collapsed" desc="Generated Code">
How to pass the value of Selected Value of combo box into sql ??
How to pass the value of Selected Value of combo box into sql ??  My SQL Database Name is MHS, user=root, password=admin,table name is sub_comb(regno,sname,sgen). Now i want to select one "regno" from Combobox and then after
Solve my code
Solve my code  import javax.servlet.*; import javax.servlet.http.... response)throws ServletException, IOException{ response.setContentType("text/html... is the mistake in this code! This is working only one record doesn't work
Probblems with printing if my innput of text file is correct..
Probblems with printing if my innput of text file is correct..  I am trying to make sure this block of code does what I think it will do. Can someone show me with some code how I can print out what is is labled with <----print
if my database(oracle) connection failure means wat is the code to write in exception ?
if my database(oracle) connection failure means wat is the code to write in exception ?  if my database(oracle) connection failure means wat is the code to write in exception
jsp login code ... when username , drop down box and password is correct
value is correct.... the drop down box values should be retrieved from database....... the value is retrieved from database into combo box..... but the validation... but its showing as wrong..... i dont know how to check the combo box selected value
how to know which jList is selected and according to that fetch the value
is selected so that i get the value of employee_id from the correct jList (i.e which is selected) to fetch data from database using selected employee id from selected...how to know which jList is selected and according to that fetch the value 
add text box and select list dynamically and get its value to store it into database using jsp request parameter
add text box and select list dynamically and get its value to store it into database using jsp request parameter  its very helpful when you have only dynamically added text field but want code to retrive value of dynamically
Code to store sub combo box value - Development process
Code to store sub combo box value  Hi Deepak, In the following code i want to store subcombo box value instead of number. Already "Dkn/Tmz" ,"kungumam... etc are storing but i want to store "Circulation,marketing
retrieve value from db in text box + calendar implementation.
there is already a text box..Now i want to get the value retrieved from database...retrieve value from db in text box + calendar implementation.  I have used http://www.roseindia.net/javascript/javascript-calendar.shtml code
Problem in my code - Development process
Problem in my code  Plz go thru this code. I want to check login and pwd with database. Backend MsAccess , Table name : Reg , Dsn Name: JJ While executing code am getting 404 error User Name Password
this is my code java - Date Calendar
this is my code java  /* * NewJFrame.java * * Created on 11... NOT modify this code. The content of this method is * always regenerated..., javax.swing.GroupLayout.DEFAULT_SIZE, 144, Short.MAX_VALUE)) .addContainerGap(123
populating text box using jsp code
populating text box using jsp code  Sir, How to populate related values in a text box after selecting value from drop down list using JSP and mysql...;%=value%>" selected disabled><%=value%></option> <
What's wrong with my pagination code in JSP?
What's wrong with my pagination code in JSP?  Dear experts, I've...; print("code sample");   JSP Pagination The given code retrieves... whatever lines that NetBean IDE has given me error signal. The resulted page
how to display jsp page containing mysql query in particular division using ajax ?my code is below bt i cundt get it properly
ajax ?my code is below bt i cundt get it properly   index.html <... type="text" name="address" id="address" value=""></td></tr> <... type="text" name="email" id="email" value=""></td></tr> <
How to assign a default value to text box in netbeans
How to assign a default value to text box in netbeans  I have a java application,and i want to assign a default variable to the textbox
Please help me to modify my java code from php code
Please help me to modify my java code from php code  i want to covert...]); $array[] = $item[1]; } } I tried like this (see below JSP code...; <tr> <td><input type="text" name="bid" value="<
code for selected checkbox columns data from database
code for selected checkbox columns data from database  in my page iam... one or more checkboxes i have to get data of that selected columns only. what is the jsp code for this thanks in advance kalyani
I need jsp code for how to write text field value into property file.
I need jsp code for how to write text field value into property file.  Hi , I need to set the text field value into property file using jsp code. Example : Username : Valar , I have entered the value "Valar" in the text field
Insert value of dynamic generated text box in jsp using javascript
that dynamically generated text box value into database at a time without...Insert value of dynamic generated text box in jsp using javascript  hello sir , i want to generate dynamic text box at run time and i did that using
Form Code To Dispay Webpages On My Site
Form Code To Dispay Webpages On My Site  I want to use a form input box to display different pages on my site depending on the code the user types into the box. example: Producer Code 1234 would bring up Producer 1 page
how to display textbox value based on selected option value?
how to display textbox value based on selected option value?  Hi,I... on first value I finished above code. ID: xx Name:xx xx is baesd on second and first value. But it is that l can't do that. now, l post my code
how to update combobx's selected value to database with respect toselected multiple checkboxes
how to update combobx's selected value to database with respect toselected... values which is selected from form1.jsp String languages=""; String box... to display records from database out.println("<tr><td>"+"<input type
how can i simplify my java code
how can i simplify my java code  /* Create a program that prompts the user to enter a password. Display a suitable message for each correct or incorrect attempt made. The user must be given three tries after which
ModuleNotFoundError: No module named 'my-first-code-in-python'
ModuleNotFoundError: No module named 'my-first-code-in-python'  Hi...: No module named 'my-first-code-in-python' How to remove the ModuleNotFoundError: No module named 'my-first-code-in-python' error? Thanks   
ModuleNotFoundError: No module named 'my-first-code-in-python'
ModuleNotFoundError: No module named 'my-first-code-in-python'  Hi...: No module named 'my-first-code-in-python' How to remove the ModuleNotFoundError: No module named 'my-first-code-in-python' error? Thanks   
My Servlet code not working - Development process
My Servlet code not working  HHi, After executing servlet am getting... Auto-generated method stub response.setContentType("text/html... ServletException, IOException { response.setContentType("text/html"); PrintWriter pw
getting null value in my class when using t:inputFileUpload
getting null value in my class when using t:inputFileUpload  getting null value in my class when using t:inputFileUpload
Not sure whats wrong with my code HELP PLEASE?!?!
Not sure whats wrong with my code HELP PLEASE?!?!  I cant figure out what I am doing wrong in my code can anyone help me out??? Grades ADS_TO_REPLACE_1 function computeGrade( ) { var hw, lab, midt, fin, avg; hw
Small Bug How to solve in my code
Small Bug How to solve in my code  String season=""; pst = con.prepareStatement("SELECT DISTINCT(Season) season FROM specialdates where Regid... +=rs.getString("season") + ","; } in above code seasons +=rs.getString("season
doubt in my program code - Java Beginners
doubt in my program code  i have developed a web browser... the code i developed i can send u to ur mail if u give ur mail id.... It would be good for me to provide you the solution if problem is clear. Plz send code
Box And Whisker Chart Example using JFreeChart
to create a box and whisker chart using JFreeChart. Code of the chart given below shows product value at different date . In the code given below we have... Box And Whisker Chart Example using JFreeChart
anyone willing to look over my code? (java)
anyone willing to look over my code? (java)  package inorder.without.cheats; import java.util.Arrays; import javax.swing.JOptionPane; public class InOrderWithOutCheats { public static void main(String[] args
i am unable to identify the error in my code
i am unable to identify the error in my code  class Program { public static void main(String[] args) { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("enter
i am unable to identify the error in my code
i am unable to identify the error in my code  class Program { public static void main(String[] args) { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("enter
ERROR with my JAVA code - Java Beginners
ERROR with my JAVA code  The error came up in my main method... it wasnt there until i finished my actionListener coding so I dont know how to fix this....it is really stressing me out!! HELP!!! import java.awt.*; import
. Display JavaScript dropdown selected value
value from dropdown box? I am using javascript.   <html> <...("dropdown").value; alert("You selected : " + dropdownValue); } <... dropdownValue we are storing the selected value by using

Ads