I have a number of value 0 on numberMath.ejs. My goal is to press a button. The button will display the view that shows the new value. The new value is calculated by a formula that I wrote in app.js.
If you want the old and the new number to appear you should send through the two as different values on render()
app.post("/numberMath",function(req,res){
tempNum = num;
num++;
res.render("numberMath", {
myNewNum: num,
myOldNum: tempNum
});
});
On the front end you can use javascript to popup the old and new numbers:
<script>
alert("Old Num: " + <%= myOldNum %> + ", New Num: " + <%= myNewNum %>);
</script>
This will get the two calculated values to the front-end each time you push the Formula
button.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.