Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Drop down looping through 53 weeks starting with this week e.g. 8, 7, 6, 5, 4, 3, 2, 1, 53, 52 etc

Posted on 2005-05-04
9
Medium Priority
?
209 Views
Last Modified: 2010-04-06
Hi,

What would be the best way to code drop down?

so far (using html and plsql) i loop through the 53 (IW calendar) weeks but cant get my head round how I would order them so you get the drop down to default to this week, descend to week 1 and then go from week 53 to this week +1 e.g.

this week = 17
drop down
Start 17,16,15,14,13.., 2, 1, 53, 52, 51,50..,21,20,19,18 Finish

Any ideas?
0
Comment
Question by:joehodge
  • 3
  • 3
  • 3
9 Comments
 

Author Comment

by:joehodge
ID: 13926564
this is my code so far.......

htp.p('<TD><SELECT NAME="p_week_number" class="tableText">');
              FOR i IN 1..53 LOOP
                               lv_tot := lv_week-lv_counter;
                              if (lv_tot = 0) then
                              lv_week := 54;
                              lv_counter := 1;
                              lv_tot := lv_week-lv_counter;
                              end if;
                              
                          htp.p('<OPTION WIDTH="40" VALUE="'||(lv_tot)||'" SELECTED >'||(lv_tot));
                          lv_counter := lv_counter +1;
              END LOOP;
   htp.p('</SELECT></TD>');
0
 
LVL 19

Accepted Solution

by:
DreamMaster earned 2000 total points
ID: 13927243
Why would you do it that way?

Why not...fill the entire drop down from 53 down to 1, find the weeknumber it is now and have that selected...seems much more logical to me...

Regards,
Max.
0
 

Author Comment

by:joehodge
ID: 13927695
Hi Max,

you're right it is more logical,

The reason (there is a small one!)  down that routeis because its a weekly report the week defaults this week and the year to this year, I therefore didn't want to have a user scrolling down to say week 18, hitting submit and then not seeing any data (as there are some multiplications going on, the page crashes without any data)

Thinking about it, i should add a bit of code to deal with zeros instead of faffing about with this drop down :-)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 13929602
you can use the integer division remider...  i don't know how that is done in peal (i assume that's what your code is written in), but it's an operation that is supported by all languages.  the operator is often "%".
the idea is to use this expression:  (thisweek - i + 53) % 53

Here is a version in javascript:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Counter</title>
</script>
</head>
<body>
<script type="text/javascript">
  var thisweek = 17;
  for (var i=0; i < 53; i++) {
    var curr = (thisweek - i + 53) % 53;
    document.write(curr + "<br>");
  }
</script>
</body>
</html>
0
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 13929641
just noticed my code prints "0" instead of "53", but that's very easy to adjust.
0
 
LVL 19

Expert Comment

by:DreamMaster
ID: 13931578
> The reason (there is a small one!)  down that routeis because its a weekly report the week defaults this week and the year to this year...

Well, wouldn't having the current month/year as the selected month/year solve that? It doesn't have to be on top in order for it to be selected....

Regards,
Max.
0
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 13931665
> Why not...fill the entire drop down from 53 down to 1, find the weeknumber it is now and have that selected...seems much more logical to me...

...actually that seems more logical to me too.  i had not read the post carefully.

reordering the weeks starting from current would be logical if there was no year selector and only one year of published archive.
in that case, if current week is 17, then 18 would refer to the week 18 of the previous year, so it should be last in the selector.
but this seems not to be the case.
0
 

Author Comment

by:joehodge
ID: 13933852
I do wish my brain worked in a logical way, sometimes it allows for some nifty creative moments but in this situation it has really let me down.

onwards and upwards!
0
 
LVL 19

Expert Comment

by:DreamMaster
ID: 13933888
Good luck joehodge, glad I was helpful :)

Regards,
Max.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question