Results 1 to 6 of 6

Thread: [RESOLVED] Separating JS from HTML

Threaded View

  1. #1
    Join Date
    Dec 2005

    resolved [RESOLVED] Separating JS from HTML

    I'm trying to separate the HTML from the JS function, but having not much luck.
    Any ideas why I can not accomplish this?
    <title> FAQ  display</title>
    <meta charset="utf-8">
    <style type="text/css">
     dt { line-height: 1.5em; }
    <h1> FAQ List </h1>
     <dl id="FAQlist">
      <dt>faq #1</dt>
      <dd>Answer to FAQ #1</dd>
       <dt>faq #2</dt>
      <dd>Answer to FAQ #2</dd>
      <dt>faq #3</dt>
      <dd>Answer to FAQ #3</dd>
      <dt>More faqs </dt>
      <dd>Answers to additional FAQs</dd>
      <!-- other Questions and Answers follow -->
    <script type="text/javascript">
    function toggleDD(IDS) {
      var tmp = document.getElementById(IDS);   
      if (tmp.style.display != 'block') { tmp.style.display = 'block'; }
                                   else { tmp.style.display = 'none'; }
    window.onload = function() {
    // set-up actions of DL, DT and DD display
      var sel = document.getElementById('FAQlist').getElementsByTagName('dt');
      for (var i=0; i<sel.length; i++) {
        sel[i].style.cursor= 'pointer';
      sel = document.getElementById('FAQlist').getElementsByTagName('dd');
      for (var i=0; i<sel.length; i++) {
        sel[i].id = 'faq'+i;
        sel[i].style.display = 'none';
    // dd and dt must match in pairings of dl list
    I'm not getting any errors, but then it doesn't do what I expect anyway ???
    Expect to toggle display for FAQ answers based upon users click.
    Last edited by JMRKER; 05-06-2013 at 12:14 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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