Click here to Skip to main content
14,387,532 members
Rate this:
Please Sign up or sign in to vote.
See more:
sir, i am making a project where i am selecting category and sub-category and after that click next but
i am not able to see order-details table.so i really want to know when the customer select multiple item
with quantity then all the detail shown in order-detail table without refreshing the page.if a customer
select one item of veg,one item of non-veg,one item of starter,one item of beverages all item detail
shown in order-detail table with total amount detail. Then i will move forward.Please help me this is the important part of my project.thanks in advance.

food1.jsp

<%@page import="org.omg.PortableServer.ForwardRequest"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

<%@ page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Food |Automation</title>
    <style>

      .veg
      {
        border:1px #ccc solid;
        height:100px;
        width:100px;
        margin:30px 0px 100px 20px;
    }
    .non-veg {
        border:1px #ccc solid;
        height:130px;
        width:105px;
        margin:-200px 0px 100px 160px;
    }


    .starter {
        border:1px #ccc solid;
        height:100px;
        width:100px;
        margin:-80px 0px 100px 20px;
    }
    .vriveg {
        border:1px #ccc solid;
        height:100px;
        width :100px;
        margin:-200px 0px 100px 160px;
    }


    .fastfood {
        border:1px #ccc solid;
        height:100px;
        width:100px;
        margin:-40px 0px 100px 20px;
    }
    .drink {
        border:1px #ccc solid;
        height:100px;
        width:100px;
        margin:-200px 0px 100px 160px;
    }


    .strip
{
        background:url(images/bg2.png);
        height:40px;
    }
    .bg1
{
        background:url(images/bg.jpg);
        text-align:center;
    }
    .mbtn
{
        background:url(images/bg.png);
        color:#fff;
        height:30px;
    }
    th
{
        background:url(images/bg.png);
        color:#FFF;
    }
    </style>
  <script type="text/javascript">
 function showtable(str)

 {
document.ElementById("table1").innerHTML+="<tr><td></td><td>"+str+"</td></tr>";
}

 function nxt1(){
           var v=confirm("Do You Want to reset order");
           if(v==true){
               window.location.replace("food1.jsp");
           }

   }
 </script>

<script>
    var request;
    function getRecord(e)
    {  //alert("dssfs");
        var str=e.name;
    var url="food45.jsp?ty="+str;
    //alert("dssfs");
    if(window.XMLHttpRequest)
    {
    request=new XMLHttpRequest();
    }else if(window.ActiveXObject)
    {
    request=new ActiveXObject("Microsoft.XMLHTTP");
    }
    try
    {
    request.onreadystatechange=getInfo1;
    request.open("GET",url,true);
    request.send();
    }catch(e){alert("Unable to connect to server");
    }
    }
    function getInfo1(){
    if(request.readyState==4){

    var val=request.responseText;
    document.getElementById('prtCnt').innerHTML=val;
    //alert("FFF ");
    }
    }
    </script>

  <script>
  function getRecords()
  {
    var di = document.getElementById("sh").value;
    var qu = document.getElementById("qua").value;
    alert(di+" "+qu);
      var xmlhttp;
      var url = "food46.jsp?ty="+di+"&qua="+qu;

      if(window.XMLHttpRequest)
      {
            request=new XMLHttpRequest();
            }else if(window.ActiveXObject)
            {
            request=new ActiveXObject("Microsoft.XMLHTTP");
            }
            try
            {
            request.onreadystatechange=getInfo2;
            request.open("GET",url,true);
            request.send();
            }catch(e)
            {
                alert("Unable to connect to server");
                }
            }
          function getInfo2()
          {
            if(request.readyState==4)
            {

            var val=request.responseText;
            document.getElementById('show').innerHTML=val;
           // alert("FFF ");
            }
            }

</script>

    </head>
<body>
     <%Connection con=null;%>
       <%PreparedStatement preparedStatement=null; %>
       <% ResultSet resultSet=null;%>

    <table width="100%" border="0" cellspacing="0">
    <tr><td><%@ include file="header.jsp" %></td></tr>
    <tr><td>
<!-- ------------------------------------------------------- -->

  <table width="100%" border="0" cellspacing="0">
      <tr>
        <td class="bg"><h3><p>Main Categories</p></h3></td>
        <td class="bg"><h3><p>Sub Categories</p></h3></td>
        <td class="bg"><h3><p>Your Order Details</p></h3></td>
      </tr>
      <tr>
        <td width="300px" class="bg1" >
        <div style=" height:400px;overflow-y:scroll;"  >
             <div class="veg"><img src=images/veg.jpg  onclick="getRecord(this)" name="veg" /></div>
             <div class="non-veg"><img src="images/nonveg.jpg" width="107" height="130" onclick="getRecord(this)" name="nonveg"></img></div>
             <div class="starter"><img src="images/Starter.jpg" width="107" height="130" onclick="getRecord(this)" name="starters"></img></div>
             <div class="vriveg"><img src="images/Beverage2.jpg" width="107" height="130" onclick="getRecord(this)" name="beverages"></img></div></a>
             <div class="fastfood"><img src="images/Bread.jpg" width="107" height="130"  onclick="getRecord(this)" name="Breads"></img></div></a>
             <div class="drink"><img src="images/Rice.jpg" width="107" height="130" onclick="getRecord(this)" name="Rices"></img></div></a>
  </div>
    </td>
        <td width="300px" class="bg1">
        <div style=" height:400px; overflow-y:scroll;">
        <h4><p style="text-align:left;width:200px;"> <div id="prtCnt">








        </div>    </p></h4>
        </div>
        </td>
        <td class="bg1">
        <!------------------------------------------>


         <!--<form action="login.jsp" name="f4" method="POST">  -->

         <form>
         <div>
    <div id="show" align=center>










     </div>

        <!--div align="right"--><br/>


      <table border="0" cellspacing="0" width="75%" align="center" style="margin:0 auto;">









        <tr>
          <td><strong>


          <a href="feedbac.jsp">Additional Comments :</a>


          </strong></td>
          <td>&nbsp;</td>
          </tr>
        <tr>
          <td>&nbsp;</td>
          <td align="right"><textarea name="textarea" cols="40" rows="6"></textarea></td>
          </tr>
        <tr>
          <td><div align="right">
          <input type="radio" name="type" value="self"> Self Service

            </div></td>
          <td><div align="center">
            <input type="radio" name="item" />
            Room Service</div></td>
          </tr>
        <tr>
          <td>
           <input type="button" value="Confirm Order" class="mbtn"/ >
         </td>
          <td><div align="right">

            <input type="button" name="btn1" value="Reset Order" class="mbtn" />
            </div>
            </td>
          </tr>
      </table>
    </div>
    </form>
<!-------------------------------------------------->
    </td>
  </tr>
  <tr>
      <td colspan="3" class="strip" align="center"></td>

    </tr>
<tr>
</table>

<!-- ------------------------------------------------------- -->
</td></tr>
<tr><td><%@ include file="footer.jsp" %></td></tr>
</table>

</body>
</html>



food45.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%@ page import="java.sql.*" %>
     <%
     Connection con=null;
          PreparedStatement preparedStatement=null;
          ResultSet resultSet=null;
//          String name ="nonveg";



            String name=request.getParameter("ty");
            System.out.println(" Type Name  : "+name);
            try {
                int n=0;
                Class.forName("com.mysql.jdbc.Driver");
                con=DriverManager.getConnection ("jdbc:mysql://localhost:3306/Auto","root","root");
                preparedStatement=con.prepareStatement("select * from items where type=? ");
                preparedStatement.setString(1, name);
                resultSet=preparedStatement.executeQuery();
                %>


                <form>
                 <table>
                    <tr><th>Name </th><th>Select</th><th>Select Quantity</th></tr>
                <%
                while(resultSet.next()) {
                                n++;
         %>
        <tr><td><%=resultSet.getString(2)%></td><td><input type="checkbox" name="c<%=n%>" value="<%=resultSet.getString(2)%>"/></td>
        <td>
            <input type="hidden" name="co<%=n%>" value="<%=resultSet.getString(3)%>">
                 <select name="q<%=n%>"  id="qua">
                 <option value="0">Select Quantity</option>
                 <option value="0.5">1/2</option><option value="1">1</option><option value="2">2</option><option value="3">3</option>
                  <option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option>

                </select>
      </td></tr>
     <%
     } con.close(); if(n>0)
     {
     %>
     <input type="hidden" name="count" value="<%=n%>">
     <tr><td colspan=3> <input type="hidden" value="showdish" name="show">

     <input type="submit" width="100" value="    Next   " onclick="getRecords(this)"></td></tr>
     <%
         }
     }catch(Exception exception)
     {
         System.out.println(exception);
     }
      %>
       </table>
       </form>
        <br>


</body>
</html>





food46.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title></title>
</head>
<body>
<%@ page import="java.sql.*" %>
     <%
     Connection con=null;
          PreparedStatement preparedStatement=null;
          ResultSet resultSet=null;



            String name=request.getParameter("ty");
                System.out.println(" Type Name  : "+name);

            try {
            %>
               <form>

                <table name="table1" border=1 width="400px">
                <tr><th>Item Name </th> <th>Quantity</th><th>Cost</th><th>Cancel</th></tr>
                <%
                float total=0;
                   int c=0;
                 if(request.getParameter("show")!=null)
                    if(request.getParameter("show").equals("showdish")){
                        int count = Integer.parseInt(request.getParameter("count"));
                        for(int i=1 ; i<=count ; i++)
                        {
                            if(request.getParameter(("c"+i))!=null)
                            {
                                c++;
                                %>
                                   <tr>
                                   <td><%=request.getParameter("c"+i)%><input type="hidden" name="c<%=i%>" value="<%=request.getParameter("c"+i)%>" id="sh"/></td>
                                   <td><%=request.getParameter("q"+i)%><input type="hidden" name="q<%=i%>" value="<%=request.getParameter("q"+i)%>"/></td>
                                  <%
                                   float co = Float.parseFloat(request.getParameter("co"+i));
                                   float qu=Float.parseFloat(request.getParameter("q"+i));
                                   float cost=co*qu;
                                  //System.out.println("Cost:"+cost);
                                  //System.out.println("Quantity:"+qu);



                                   total=total+cost;
                                   %>
                                   <td><%=cost%><input type="hidden" name="co<%=i%>" value="<%=cost%>"/></td>
                                   </tr>
                                <%
                            }
                        }

                    }
                %>

                 </table>
                 </form>
                 <table width="75%" align="left" style="margin:0px 0 120px 0px;">

         <tr>
                <td><strong>Total &nbsp;&nbsp;  :</strong></td>



        <td><input type="hidden" name="count" value="<%=c%>"/>

       <div align="right" >

       <input type="text" name="total2" value="<%=total%>" readonly="true">


            </div>
            </td>
            </tr>


             </table>




<%
}catch(Exception e)
{System.out.print("errpor :"+e);

}%>

</body>
</html>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100