I'm trying to make a basic cash register app. How do I pass the form data from this:
String getExternalIds = "/FundShareClass/Fund/PortfolioList/Portfolio/Holding/HoldingDetail/@_ExternalId";
List<String> externalIdList = new ArrayList<String>();
XPath xPath = XPathFactory.newInstance().newXPath();
NodeList nodeList = (NodeList) xPath.compile(getExternalIds).evaluate(doc, XPathConstants.NODESET);
for (int i = 0; i < nodeList.getLength(); i++)
{
externalIdList.add(nodeList.item(i).getFirstChild().getNodeValue() + '\n');
}
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/TestDb";
String user = "root";
String pass = "";
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = (Connection) DriverManager.getConnection(url, user, pass);
System.out.print("Connection Made to Mysql Database");
for(String externalId : externalIdList)
{
try
{
String currentId = externalId;
String query = "SELECT * FROM StructuredMappings WHERE managerCode=?";
PreparedStatement ps = conn.prepareStatement(query);
ps.setString(1, externalId);
ResultSet rs = ps.executeQuery();
Boolean response = rs.next();
System.out.println(response);
while(rs.next())
{
System.out.println("MAPPING CODE FOUND");
String ISIN = rs.getString("ISIN");
String idType = rs.getString("type");
System.out.println(ISIN +" , " +idType);
}
into the methods listed below everytime something is submitted
<form action="#" id="target">
<input type="text" required class="field1 col-md-3 col-md-offset-3" placeholder="Enter Item Name Here">
<input type="text" required class="field1 col-sm-2 " placeholder="Enter Item Quantity">
</div>
<div class="row">
<input type="text" class="field1 col-md-3 col-md-offset-3" placeholder="Enter Staff Name (Optional)">
<button type='submit' class="col-md-2 butn btn-one" id="check">Checkout</button>
</div>
then print the results of the script from the console to the HTML page
cashRegister.scan('ITEM NAME', QUANTITY);
// Apply your staff discount
// applying a staff discount to the total amount
cashRegister.applyStaffDiscount(EMPLOYEE);
I want to be able input a quantity of 5 for an item of apples, on my discount and have that form spit out this following JavaScript to execute this script http://codepen.io/illusionelements/pen/xGQrxN
console.log('Your bill is ' + cashRegister.total.toFixed(2));
答案 0 :(得分:0)
It looks like the problem you're having is that you're trying to get the values of the form to the javascript. If that's the case then try something like this:
parent.children.push(child);
A couple things you'd need to do to make this work:
make an object of your staff members
$('#check').on('click', function(e) {
e.preventDefault(); //Stops the form from being posted
var item = $('#item').val();
var quantity = $('#quantity').val();
var staff = $('#staff').val();
cashregister.scan(item, quantity);
if(staff.length > 0 && typeof staffMembers[staff] != 'undefined')
{
cashregister.applyStaffDiscount(staffMembers[staff]);
}
console.log('Your bill is ' + cashRegister.total.toFixed(2));
$('#target2').fadeIn(5000)
// .animate({opacity: 0.5}, 3000)
.fadeOut(5000);
});