0

JAVASCRIPT

const address = '0x2537155193458a51c99d840e3dBc1f60E004aA85';
var contract = new web3.eth.Contract(abi,address);
console.log(contract);
$('#invoice-btn').click(function(){
contract.methods.genInvoice($('#invoice').val(),$('#productName').val(),$('#date').val(),$('#prodQuantity').val(),$('#unitPrice').val(),$('#gst').val()).send({from:"0x6F43d25a062e2cb48bF83dB76afC797210321945", gas:300000})});
  });

I sent this form data to the smart contract on a click event. Now what i want is that as soon as the data is sent,a new page loads and i get this data on that new page.

JAVASCRPT

Following is the code which i have written to get data back from the smart contract. This script will run when the new page is loaded. The data returned will be injected in the specific portions of the html document.

contract.methods.getPriceDetails(invoiceNo).call().then(price=>{console.log(price)});
contract.methods.getProductDetails(invoiceNo).call().then(prod=>console.log(prod));

Someone please suggest me a way to achieve this. Should i put an anchor tag around the button and then render a new page. I am using express server on localhost:3000

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.