Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7606047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:18:49+00:00 2026-05-31T00:18:49+00:00

Alright… I’m trying to write some javascript code that will apply to an html

  • 0

Alright… I’m trying to write some javascript code that will apply to an html block, which itself appears in a javascript file. It’s a complete mess. Here’s a sample:

[new Date(1942,01,01), , '<div onclick="this.nextSibling.style.display=\'block\'; this.style.display=\'none\'"><img src="img/content/michenerCenterThumb.jpg" style="cursor:pointer" /></div><div style="display:none"><iframe width="200" height="165" src="http://www.youtube.com/embed/in7IUzjN3pY?rel=0" frameborder="0" allowfullscreen></iframe>'],

[edit] I’m using Timeline, which is available here: http://links.sourceforge.net/#timeline. Part of building a timeline involves adding entries, like in this sample:

data.addRows([
      [new Date(2010,7,23), , 'Conversation<br>' + 
        '<img src="img/comments-icon.png" style="width:32px; height:32px;">'],
      [new Date(2010,7,23,23,0,0), , 'Mail from boss<br>' + 
        '<img src="img/mail-icon.png" style="width:32px; height:32px;">'],
      [new Date(2010,7,24,16,0,0), , 'Report'],
      [new Date(2010,7,26), new Date(2010,8,2), 'Traject A'],     
      [new Date(2010,7,28), , 'Memo<br>' + 
        '<img src="img/notes-edit-icon.png" style="width:48px; height:48px;">'],
      [new Date(2010,7,29), , 'Phone call<br>' + 
        '<img src="img/Hardware-Mobile-Phone-icon.png" style="width:32px; height:32px;">'],
      [new Date(2010,7,31), new Date(2010,8,3), 'Traject B'],     
      [new Date(2010,8,4,12,0,0), , 'Report<br>' +
        '<img src="img/attachment-icon.png" style="width:32px; height:32px;">']
    ]);

In the html, I want to implement jquery ui, highslider, etc., but this becomes messy very fast (like in my above example.) What is “doing it right” in this instance?

Thanks,

Ben

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:18:50+00:00Added an answer on May 31, 2026 at 12:18 am

    I came up with a more elegant solution… closer, I hope, to what constitutes proper coding. The html of each element is now written on the html page. I read this by using a custom getElementsByClassName which inserts each item class into an array. This array then populates the timeline.

    The html:

    <div class="item" date="1956,1,1" enddate="1967,1,1">
    Some Content    
    </div>
    

    and the javascript:

    var items = getElementsByClassName("item"); 
        for (var x = 0; x < items.length; x++) {
             var date = items[x].getAttribute("date"); 
             var enddate = items[x].getAttribute("enddate"); 
             var html = items[x].innerHTML; 
                if (!enddate) {
                    items[x]=[new Date(date), enddate, html];
                } else {         
                    items[x]=[new Date(date), new Date(enddate), html]; 
                }
            }
    
        data.addColumn('datetime', 'start');
        data.addColumn('datetime', 'end');
        data.addColumn('string', 'content');
    
        data.addRows(items);
    

    You can find the custom getElementsByClassName here: http://code.google.com/p/getelementsbyclassname/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright y'all. I am attempting to write a bit of code that places typographic
Alright when I do the code: <script type = text/javascript > document.write((new Date).getTime()); </script>
Alright, here's what I'm trying to do. I'm attempting to write a quick build
Alright I'm pretty new to programming and stuff and I'm now trying to code
Alright, so I've been trying to implement a simple binary search tree that uses
Alright, currently I have my SWF hitting a php file that will go and
Alright, I'm trying to read a comma delimited file and then put that into
Alright, here we go! I am currently developing an iPhone app that will work
Alright, I am trying to accomplish this: When a user clicks a button that
alright, I'm trying something which should be like really easy. Here it is: usort($newarr,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.