I am needing to generate a reference number using jQuery (I understand not the best method, but best I have to work with).
Each existing number is inserted as a class, these are hidden on the page, just available for this use:
<div class="Ref 14001"></div>
<div class="Ref 14002"></div>
<div class="Ref 14003"></div>
The Reference number is sequential, and the "14" prefix denotes the year. At the start of each year the number needs to reset as "YY001". So at the start of 2015 I need it to automatically change to:
<div class="Ref 15001"></div>
So what needs to happen is when the page is loaded a script runs, finds the most recent number, in this case "14003", I need to then check the first two numbers are the current year, if not, update and reset the number. If they are, just add "1" (14004) and insert into a field:
<input type="text" class="ref-number" name="ref-number" />
My jQuery knowledge is very basic, so code samples or jFiddles would be greatly appreciated. Thanks for any assistance in advance.
EDIT: Thanks for directing me to those posting guidelines, I will endeavour to post my examples. I have a jsFiddle for the first part of my question. I can find the largest number (by class then ID from suggestion) and increase by 1: http://jsfiddle.net/PKMYy/
It's the other part of my problem that I don't even know where to start.