Teaching Newbies since 2014

  • Home
  • Javascript ❤
    • JavaScript
    • Node.js
  • WebDev Tuts
  • screencasts
  • Resources
  • VR & AR
  • Github
  • Twitter
  • YouTube
  • RSS
  • C++
You are here: Home / Tips&Tricks / Tricks learned this month

August 25, 2019 by: Kauress

Tricks learned this month

  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);

 

 

Conditionally rendering EJS template with res.locals in express.js
Plug-n-Play authentication is officially out now!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2022 ·Kauress

Go to mobile version