Link to home
Start Free TrialLog in
Avatar of Graeme McGilvray
Graeme McGilvrayFlag for Australia

asked on

Adding in a Year title

Hi all, I would like to add a small detail to my site, however I am unsure where to start...

My dev site: 

What I would like to do is have the year separating the products, like:

As you can see at the top of the page is has separated the 2021 products and the 2022 products.

Again I am unsure how I can do this, I am using ASP Classic and getting data from Access

Avatar of ste5an
Flag of Germany image

hmm, without seeing your attempts, you need to start with the overall layout in HTML/CSS/JS first. It's structure must reflect the grouping of your data. Then you can apply it in your code.

What you need to do exactly depends on the used approach and design principles.

E.g. it can be a additional sort column in your existing record set with an additional loop over the year or a separate record set with a loop over it. Or it can be just a additional sort column in your existing record and the grouping is done in JS.

p.s. posting nothing here about is not a good idea. Always include screenshots of the as-is state and sketches of the desired output. Especially as your page is currently not working (error '80020009' /home.asp, line 85).
Avatar of Graeme McGilvray


Hi Ste5an, as I have already previously mentioned, I am unsure where to start... so no attempts yet.

Both links work for me, perhaps check again?

I thought i explained it pretty clearly and gave an example page of what it would look like
Nope, still not working...

But I wrote what you can do, which depends on your design and coding principles of the unknown, cause unseen current state of your site and its code behind.
Just apply one of those ways.
Both work for me...

Unfortunately none of what you recommended made any sense, sorry
I have been having a play with some code, not sure if I am on the right track:

    If Year(Prod("dep_date"))=ShowYear Then
    <td colspan=20 height=20><%=Year(Prod("dep_date"))%></td>
    <td colspan=20 height=20></td>
    End If

Open in new window

It doesnt work, but im sure with some tweaks, it may (if im on the right track)
This should be the structure of your unseen page right now:

User generated image
Right now you should have the orange and green components. Thus you need to add the blue component layer. One way to do it:

As it is ASP classic, you do this be starting at the data source. You need to simply add the year to it and sort it by year first and then by the old sort columns.
In your existing loop you add at the beginning the logic to detect a year change, a standard column value change detection. When the value changes you close the old div and open a new one with and year header.

I have been having a play with some code, not sure if I am on the right track.
That's why I asked for screenshots and sketches. Cause you don't have an good inner vision of the design and its components and probably even its HTML/CSS representation...
Avatar of Graeme McGilvray
Graeme McGilvray
Flag of Australia image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Clean code is your friend:

  ActiveYear = 0
  Do Until Prod.EOF
    CurrentYear = Year(Prod("dep_date"))
    If CurrentYear <> ActiveYear Then
      ActiveYear = CurrentYear
  <tr><td colspan=20 height=20><b4><%=ActiveYear%> Events</b4></td></tr>
  <tr><td colspan=20 height=20></td></tr>
    End If


Open in new window

p.s. this is exactly one of my suggestions.