Skip to main content
Tips&TricksWeb Dev

Tricks learned this month

By August 25, 2019No Comments
  1. To ignore remote changes and overwrite them

git push origin --force

  1. The token conveyor belt:  use hidden input fields to pass  ‘info’ between POST & GET requests (if  there is no user entered info into an input field which can be  ‘gotten’ through req.body).

Use case:  in script.js  assign the value of  an element’s “innerHTML” property to be the value of a  hidden input. This is useful if the innerHTML property’s value is dynamic and depends on some prior user action:

In index.ejs:

<input type="hidden" name="amount value ="" id="checkoutinput>

In script.js:

var checkoutinput = document.getElementById("checkoutinput");

checkoutinput.value = cart.grandTotal.toFixed(2);

 

 

Leave a Reply