Forum Discussion
KenCasser
8 years agoQrew Cadet
The choices of Pages were Home Page, Rich Text Page and Code Page. Not "edit or add record page". As I said, I'm missing something very basic. I have tables with fields, forms and pages, but I can't figure out where the code goes...
KenCasser
8 years agoQrew Cadet
You're way ahead of me. I have to read up on ?a=er and ?a=nwr. I'm not quite comfortable with those things yet, but I appreciate you pointing me in the right direction. The lovely code is:
var date = new Date();
var yr = date.toDateString().substr(-2);
var mo = date.getMonth()+1;
var d = date.getDate();
var da = d.toString();
var a;
if (localStorage.getItem("c") !== da) {
localStorage.setItem("b", 0);
localStorage.setItem("c", da);
}
if (localStorage.getItem("b")) {
a = parseInt(localStorage.getItem("b"))+1;
localStorage.setItem("b", a);
} else {
localStorage.setItem("b", 0);
a = parseInt(localStorage.getItem("b"));
}
function leadingZero(mo) {
if (mo <= 9) {
mo = "0" + mo;
}
return mo;
}
I'm sure there are more elegant ways to do what I'm trying to do, but considering my experience level with QB & JavaScript (maybe a month in QB and a week learning js), I'm quite happy. The point is to establish a numbering system for generating our Quotation Numbers. We want every quote number to be yymmdd## where the ## for the first quote of the day is 01, and increments as quotes are generated that day. The next day we reset back to 01. My problem with doing a native QB formula is that I couldn't figure out how to increment the numbers and I couldn't figure out how to do the reset. i.e., I don't know how to store a value and retrieve it later in QB.
var date = new Date();
var yr = date.toDateString().substr(-2);
var mo = date.getMonth()+1;
var d = date.getDate();
var da = d.toString();
var a;
if (localStorage.getItem("c") !== da) {
localStorage.setItem("b", 0);
localStorage.setItem("c", da);
}
if (localStorage.getItem("b")) {
a = parseInt(localStorage.getItem("b"))+1;
localStorage.setItem("b", a);
} else {
localStorage.setItem("b", 0);
a = parseInt(localStorage.getItem("b"));
}
function leadingZero(mo) {
if (mo <= 9) {
mo = "0" + mo;
}
return mo;
}
I'm sure there are more elegant ways to do what I'm trying to do, but considering my experience level with QB & JavaScript (maybe a month in QB and a week learning js), I'm quite happy. The point is to establish a numbering system for generating our Quotation Numbers. We want every quote number to be yymmdd## where the ## for the first quote of the day is 01, and increments as quotes are generated that day. The next day we reset back to 01. My problem with doing a native QB formula is that I couldn't figure out how to increment the numbers and I couldn't figure out how to do the reset. i.e., I don't know how to store a value and retrieve it later in QB.