I am using JSP as my backend for my HTML and I want to get the customer name when I start entering the customer contact number.
HTML:
<html>
<body>
    <script>
        function evaluation() {
            var myBox1 = document.getElementById('milk').value;
            var result = document.getElementById('result');
            var myResult = myBox1 * 35;
            result.value = myResult;
        }
    </script>
    <form action="BillValid.jsp" method="post">
        <table width="70%" cellspacing="30" color="#FFFFFF">
            <tr>
                <th>ENTER THE DETAILS</th>
            </tr>
            <tr>
                <td><font color="#800000">Customercontact</font></td>
                <td><input name="cus_contact" type="text" id="contact"></td>
            </tr>
            <tr>
                <td><fontcolor="#800000">CustomerName</font></td>
                <td><input type="text" name="cus_name"></td>
            </tr>
            <tr>
                <td> </td>
                <td></td>
            </tr>
            <tr>
                <td><font color="#800000">DayConsumption</font></td>
                <td><input id="milk" type="text" name="days_con"
                    oninput="evaluation()"></td>
            </tr>
            <tr>
                <td><font color="#800000">SumInRs</font></td>
                <td><input id="result" name="total"</td>
            </tr>
            <tr>
                <td> </td>
                <td></td>
            </tr>
        </table>
        <input type="submit" name="Register"><input type="reset"
            name="reset">
    </form>
</body>
</html>    
JSP:
 try{
    String DBuser="root";
    String DBpassword="qwerty";
    String Connection="jdbc:mysql://localhost:3306/online";
    Class.forName("com.mysql.jdbc.Driver");
    java.sql.Connection conn=DriverManager.getConnection(Connection,DBuser, DBpassword);
    out.println("Database Succesfully connected");            
    String CustomerName=request.getParameter("cus_name");
    String contact=request.getParameter("cus_contact");
    long customerCon=Long.parseLong(contact);  
    String dayCons=request.getParameter("days_con");
    int Consumtion=Integer.parseInt(dayCons);
    String total =request.getParameter("total");
    int totalConsume=Integer.parseInt(total);
    String sql = "select (CustomerName) from customer where CustomerContact='"+ customerCon+"'"; 
    java.sql.PreparedStatement st=conn.prepareStatement(sql); 
    java.sql.PreparedStatement pst=conn.prepareStatement("insert into invoice (CustomerContact ,CustomerName ,LitresConsumed ,TotalSum) values (?,?,?,?)");
    pst.setLong(1, customerCon); 
    pst.setString(2, CustomerName); 
    pst.setInt(3, Consumtion); 
    pst.setInt(4, totalConsume); 
    int i=pst.executeUpdate(); 
    if(i>0){
        response.sendRedirect("BillData.jsp");
    }else{
        response.sendRedirect("addcustomer.jsp");
    }           
}catch(Exception e){
    out.println(e);
    e.getMessage();
}
 
    