Click here to Skip to main content
12,453,672 members (78,725 online)
   

Java

 
AnswerRe: Queue implementation in java Pin
Amarnath S4-May-13 5:48
memberAmarnath S4-May-13 5:48 
QuestionHelps, Rijndael on java swing Pin
code99013-Mar-13 23:20
membercode99013-Mar-13 23:20 
AnswerRe: Helps, Rijndael on java swing Pin
Nagy Vilmos14-Mar-13 1:07
memberNagy Vilmos14-Mar-13 1:07 
GeneralRe: Helps, Rijndael on java swing Pin
code99015-Mar-13 0:15
membercode99015-Mar-13 0:15 
QuestionThread implementation in Eclipse Plug-in Pin
KishoreT13-Mar-13 6:19
memberKishoreT13-Mar-13 6:19 
QuestionRegarding K-means Text Clustering Pin
sunny funny12-Mar-13 21:43
membersunny funny12-Mar-13 21:43 
AnswerCross posted from C# forum Pin
Pete O'Hanlon12-Mar-13 22:05
protectorPete O'Hanlon12-Mar-13 22:05 
Questionwhat is the difference between sendRedirect() and forward()? Pin
venky002811-Mar-13 19:38
membervenky002811-Mar-13 19:38 
AnswerRe: what is the difference between sendRedirect() and forward()? Pin
Sandeep Mewara11-Mar-13 20:44
mvpSandeep Mewara11-Mar-13 20:44 
AnswerRe: what is the difference between sendRedirect() and forward()? Pin
vkscool24-Mar-13 21:01
membervkscool24-Mar-13 21:01 
QuestionHow to use time picker in jsp? Pin
Phyo Thinzar Aung10-Mar-13 23:26
memberPhyo Thinzar Aung10-Mar-13 23:26 
AnswerRe: How to use time picker in jsp? Pin
Richard MacCutchan10-Mar-13 23:39
mvpRichard MacCutchan10-Mar-13 23:39 
AnswerRe: How to use time picker in jsp? Pin
Shubhashish_Mandal14-Mar-13 0:26
memberShubhashish_Mandal14-Mar-13 0:26 
QuestionHelp For Creating JSP invoice Pin
eMaM1519878-Mar-13 23:37
membereMaM1519878-Mar-13 23:37 
Hi ...

I have tried to create Jsp Invoice but i have some problem i hope you can help me to do it ..

Blush | :O


This the javascript used to get price for the item
var xmlHttp
   var xmlHttp
   function showState(str){
       if (typeof XMLHttpRequest != "undefined"){
           xmlHttp= new XMLHttpRequest();
       }
       else if (window.ActiveXObject){
           xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
       }
       if (xmlHttp==null){
           alert("Browser does not support XMLHTTP Request")
           return;
       }
       var url="getprice.jsp";
       url +="?count="+encodeURI(str);
       xmlHttp.onreadystatechange = stateChange;
       xmlHttp.open("GET", url, true);
       xmlHttp.send(null);
   }
 
   function stateChange(){
       if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
           document.getElementById("price").innerHTML=xmlHttp.responseText
       }
   }





This is the Inovice Page at JSP


<%-- 
    Document   : invoicedev
    Created on : Mar 6, 2013, 3:27:07 PM
    Author     : eMaM
--%>
 
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
 
<%
            response.setCharacterEncoding("UTF-8");
            request.setCharacterEncoding("UTF-8");
            String user = "root";
            String password = "0122308791";
            String host = "jdbc:mysql://localhost:3306/POSWITHACCOUNT";
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            Connection con = DriverManager.getConnection(host, user, password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT * FROM ITEMS");
 
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
    <HEAD>
        <TITLE> Add/Remove dynamic rows in HTML table </TITLE>
        <link rel="stylesheet" href="style.css">
        <link rel="license" href="http://www.opensource.org/licenses/mit-license/">
        <script src="script.js"></script>
        <script src="jquery.js" type="text/javascript"></script>
        <SCRIPT language="javascript">
 
             
 

            function getrow() {
                if (!document.getElementsByTagName || !document.createTextNode) return;
                var rows = document.getElementById('dataTable').getElementsByTagName('tr');
                var rowtyp=0;
                for (i = 0; i < rows.length; i++) {
                    rows[i].onclick = function() {
                        rowtyp= this.rowIndex + 1;
                        
                    }
                }
 
                
               
            }
 

 
            
 

                        
 
            function addRow(tableID) {
 
                var table = document.getElementById(tableID);
 
                var rowCount = table.rows.length;
                var row = table.insertRow(rowCount);
 
                var colCount = table.rows[0].cells.length;
 
                for(var i=0; i<colCount; i++) {
 
                    var newcell = row.insertCell(i);
 
                    newcell.innerHTML = table.rows[1].cells[i].innerHTML;
                    // alert(newcell.childNodes);
                   
                    
                }
                 
            }
 
            function deleteRow(tableID) {
                try {
                    var table = document.getElementById(tableID);
                    var rowCount = table.rows.length;
 
                    for(var i=0; i<rowCount; i++) {
                        var row = table.rows[i];
                        var chkbox = row.cells[0].childNodes[0];
                        if(null != chkbox && true == chkbox.checked) {
                            if(rowCount <= 1) {
                                alert("Cannot delete all the rows.");
                                break;
                            }
                            table.deleteRow(i);
                            rowCount--;
                            i--;
                        }
 

                    }
                }catch(e) {
                    alert(e);
                }
            }
 
        </SCRIPT>
    </HEAD>
    <BODY>
        <h1>Recipient</h1>
        <address contenteditable>
            <p>Some Company
c/o Some Guy</p>
        </address>
        <form>
        <table class="meta">
            <tr>
                <th><span contenteditable>Invoice #</span></th>
                <td><span contenteditable>101138</span></td>
            </tr>
            <tr>
                <th><span contenteditable>Date</span></th>
                <td><span contenteditable>January 1, 2012</span></td>
            </tr>
            <tr>
                <th><span contenteditable>Amount Due</span></th>
                <td><span id="prefix" contenteditable>$</span><span class="status"><INPUT type="text" name="eStop" id="eStop" /></span></td>
            </tr>
        </table>
 

 

        <TABLE id="dataTable" width="350px" border="1" class="inventory">
            <thead>
                <tr >
                    <th width="30px"><span contenteditable>No</span></th>
                    <th><span contenteditable>Items</span></th>
                    <th><span contenteditable>Description</span></th>
                    <th><span contenteditable>Quantity</span></th>
                    <th><span contenteditable>Price</span></th>
                    <th><span contenteditable>Tax</span></th>
                    <th><span contenteditable>Total</span></th>
                </tr>
            </thead>
            <TR >
                <TD width="30px"><INPUT type="checkbox" name="chk" /></TD>
 
                <TD>
                    <SELECT name="items" onclick="showState(this.value)" onkeydown="showState(this.value)" onkeyup="showState(this.value);getrow()" class="uname">
                        <OPTION value="in">Select Items to Sale . .</OPTION>
                        <% while (rs.next()) {%>
                        <option value="<%=rs.getInt("idITEMS")%>"><%=rs.getString("ITEMNAME")%></option>
                        <%}%>
 
                    </SELECT>
                </TD>
                <TD><INPUT type="text" name="desc"/></TD>
                <TD><INPUT type="text" name="quantity"/></TD>
                <TD><div id="price"><INPUT type="text" name="price" value="0.0" /></div></TD>
                <TD><INPUT type="text" name="tax"  id="val" value="0.0"/></TD>
                <TD><INPUT type="text" name="total" value="0.0"/></TD>
            </TR>
 
        </TABLE>
        
        
 

 
        <INPUT type="button" value="+" onclick="addRow('dataTable')" class="add"/>
 
        <INPUT type="button" value="deket" onclick="deleteRow('dataTable')" />
 
        </form>
 
    </BODY>
</HTML>



THIS IS THE getprice.jsp

page to get price
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
 
<%
            response.setCharacterEncoding("UTF-8");
            request.setCharacterEncoding("UTF-8");
            String user = "root";
            String password = "0122308791";
            String host = "jdbc:mysql://localhost:3306/POSWITHACCOUNT";
            String buffer = "";
            try {
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                Connection con = DriverManager.getConnection(host, user, password);
                Statement stmt = con.createStatement();
                ResultSet rs = stmt.executeQuery("SELECT SALEPRICE,BARCODE FROM ITEMS WHERE idITEMS='"+request.getParameter("count")+"'");
                double price=0.0;
                while (rs.next()) {
                    price=rs.getDouble("SALEPRICE");
                }
                out.println(price);
                buffer = buffer + "<INPUT type='text' name='price' value='"+price+"'/>";
                response.getWriter().println(buffer);
            } catch (Exception e) {
                System.out.println(e);
            }
%>


The problem now

when i add new row and select item the item price affect at the price cell at the first row only ??


Now how can i went add new row and select new item the price of item show at the it`s row ?
AnswerRe: Help For Creating JSP invoice Pin
Richard MacCutchan10-Mar-13 23:37
mvpRichard MacCutchan10-Mar-13 23:37 
QuestionAudio Sample Playback Pin
dusty_dex7-Mar-13 15:46
memberdusty_dex7-Mar-13 15:46 
AnswerRe: Audio Sample Playback Pin
Richard MacCutchan7-Mar-13 21:58
mvpRichard MacCutchan7-Mar-13 21:58 
Questionjtds connection problem.... SQL Server 2012 Express Pin
MacRaider47-Mar-13 3:22
memberMacRaider47-Mar-13 3:22 
AnswerRe: jtds connection problem.... SQL Server 2012 Express Pin
MacRaider47-Mar-13 7:03
memberMacRaider47-Mar-13 7:03 
AnswerHibernate Data base connection lost Pin
kvsravindrareddy12-Mar-13 21:04
memberkvsravindrareddy12-Mar-13 21:04 
SuggestionRe: jtds connection problem.... SQL Server 2012 Express Pin
Prasad Khandekar2-May-13 20:12
professionalPrasad Khandekar2-May-13 20:12 
QuestionRetails invoice Pin
eMaM1519877-Mar-13 0:39
membereMaM1519877-Mar-13 0:39 
AnswerRe: Retails invoice Pin
Sandeep Mewara7-Mar-13 1:24
mvpSandeep Mewara7-Mar-13 1:24 
Questionjava help Pin
okedi5-Mar-13 22:15
memberokedi5-Mar-13 22:15 
AnswerRe: java help Pin
Richard MacCutchan5-Mar-13 22:22
mvpRichard MacCutchan5-Mar-13 22:22 
Questiondemende help Pin
لحن الأماني5-Mar-13 9:50
memberلحن الأماني5-Mar-13 9:50 
AnswerRe: demende help Pin
Master.Man19805-Mar-13 10:21
memberMaster.Man19805-Mar-13 10:21 
Questiondemende help Pin
لحن الأماني5-Mar-13 9:50
memberلحن الأماني5-Mar-13 9:50 
AnswerRe: demende help Pin
dusty_dex6-Mar-13 4:52
memberdusty_dex6-Mar-13 4:52 
Questiondemende d'aide Pin
لحن الأماني5-Mar-13 8:17
memberلحن الأماني5-Mar-13 8:17 
AnswerRe: demende d'aide Pin
Jibesh5-Mar-13 8:47
memberJibesh5-Mar-13 8:47 
SuggestionRe: demende d'aide Pin
Richard MacCutchan5-Mar-13 9:46
mvpRichard MacCutchan5-Mar-13 9:46 
GeneralRe: demende d'aide Pin
dusty_dex6-Mar-13 0:31
memberdusty_dex6-Mar-13 0:31 
GeneralRe: demende d'aide Pin
Richard MacCutchan6-Mar-13 0:39
mvpRichard MacCutchan6-Mar-13 0:39 
GeneralRe: demende d'aide Pin
dusty_dex6-Mar-13 4:43
memberdusty_dex6-Mar-13 4:43 
Questionjava Pin
javed alm4-Mar-13 18:38
memberjaved alm4-Mar-13 18:38 
AnswerRe: java Pin
Richard MacCutchan4-Mar-13 23:19
mvpRichard MacCutchan4-Mar-13 23:19 
QuestionJava Server read txt file and compare to data in Excel file. Pin
EuphorialXTC4-Mar-13 8:49
memberEuphorialXTC4-Mar-13 8:49 
AnswerRe: Java Server read txt file and compare to data in Excel file. Pin
Richard MacCutchan4-Mar-13 23:18
mvpRichard MacCutchan4-Mar-13 23:18 
GeneralRe: Java Server read txt file and compare to data in Excel file. Pin
EuphorialXTC4-Mar-13 23:22
memberEuphorialXTC4-Mar-13 23:22 
Questionandroid app Pin
StudentGirl3-Mar-13 19:36
memberStudentGirl3-Mar-13 19:36 
AnswerRe: android app Pin
Sandeep Mewara3-Mar-13 20:13
mvpSandeep Mewara3-Mar-13 20:13 
GeneralRe: android app Pin
StudentGirl5-Mar-13 4:03
memberStudentGirl5-Mar-13 4:03 
QuestionHow to manipulate a combo box? Pin
Member 98295361-Mar-13 23:28
memberMember 98295361-Mar-13 23:28 
AnswerRe: How to manipulate a combo box? Pin
Richard MacCutchan1-Mar-13 23:59
mvpRichard MacCutchan1-Mar-13 23:59 
QuestionImage Mosaicing Pin
rachit1328-Feb-13 19:03
memberrachit1328-Feb-13 19:03 
QuestionCan we have Scala added to the list? Pin
dusty_dex26-Feb-13 6:48
memberdusty_dex26-Feb-13 6:48 
AnswerRe: Can we have Scala added to the list? Pin
jschell26-Feb-13 9:04
memberjschell26-Feb-13 9:04 
GeneralRe: Can we have Scala added to the list? Pin
dusty_dex26-Feb-13 9:42
memberdusty_dex26-Feb-13 9:42 
Questionchoise of framework for end of study Pin
simontifo25-Feb-13 2:33
membersimontifo25-Feb-13 2:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 26 Aug 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid