...

View Full Version : dynamically obtaining and inserting the current month



john_m
11-07-2006, 10:59 PM
I am attempting to make an events page that uses an "accordion" menu. I would like to be able to get the current month and insert that value into my javascript so that the when the page loads the accordion for the current month is opened. An example of what I have so far can be seen here (http://caenim.com/bisign/motorcycles-rottler.de/events/) and the javascript here (http://caenim.com/images/accordion-js.png). As you can see in the screenshot, I already have the code that returns the current month and writes out '#currentmonth' (lines 1-7, this is where the #november at the top of the page comes from). However I cannot figure out how to properly insert these values into the lower part of the javascript where the initially opened accordion part is determined (line 49 - '#november').

I am brand new to javascript so hopefully I didn't butcher the explanation too badly.

brandonH
11-07-2006, 11:17 PM
im assuming you are using <a>'s (anchor tags) because you are using the #.
which mean i think you are trying to get the page to jump to that portion of the page when it loads.

if so then you just need to do as so:
var monthvariable= //the value of what your script grabs already i.e. "#november"
window.location=monthvariable;


this will cause the page to jump straight to the anchor tag <a name=november></a>

john_m
11-07-2006, 11:49 PM
Thanks for the tip, while it wasn't a simple "just copy/paste" your suggestion it did get my mind headed down the right track (which is actually more useful for learning in the long run).

The solution was to change line 47 to:


$.accordian('#events_list > div', '#' + myMonth[thisMonth], {

Thanks again.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum