Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    dynamically obtaining and inserting the current month

    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 and the javascript here. 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.

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    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>
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #3
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •