Page 1 of 5 123 ... LastLast
Results 1 to 10 of 50

Thread: javascript help

  1. #1
    Administrator Alan92RTTT's Avatar
    Join Date
    Jul 2010
    Owner Since
    02/1998

    Location
    Madison Heights, Mi
    Posts
    2,958
    Blog Entries
    7
    Thanks
    16
    Thanked 675 Times in 255 Posts

    javascript help

    I'm having an issue with this code
    PHP Code:
    <head>
    <
    style>
        
    div.div_3sg
        
    {
            
    width100%;
        }
        
    div.tab_3sg
        
    {
            
    border1px solid;
            
    marginauto;
            
    clearboth;
            
    height120px;
            
    width98%;
            
    padding-left4px;

        }
        
    #tabs li {
            
    list-stylenone outside none;
        }
        
    #tabs ul {
            
    padding0;
            
    border-bottom0 none !important;
        }

        
    #tabs li, #tabs li a {
            
    floatleft;
        }
        
    #tabs ul li{
            
    font-weightbold;
            
    padding8px;
            
    text-decorationnone;
            
    cursorpointer;
        }
    </
    style>
    </
    head>
    <
    script type="text/javascript">
        
    document.write("\<script src='//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' type='text/javascript'>\<\/script>");
    </script>
    <body>
    <div id="tabs" class="div_3sg">
        <div style="display: block; float: left; ">
           <ul>
    <script type="text/javascript">
        jQuery.getJSON( "include_js.php",function(data){
            jQuery.each(data.groups, function(id, group){
                var a=1;
                document.writeln('<li id="#tab-'+(id+1)+'">A'+group.name+'</li>');

            });
        });

    </script>
           </ul>
        </div>
    </div>

    </body> 
    That code produces the following result.

    PHP Code:
    <li id="#tab-1">AEvents</li>
    <
    li id="#tab-2">AGroups</li>
    <
    li id="#tab-3">AInformation</li
    Can anyone see why its freaking out and clearing everything off the page.

  2. #2
    |RLII Photography| Not Verified
    Join Date
    Sep 2010
    Owner Since
    2004

    Location
    Rocket City, AL
    Posts
    221
    Thanks
    7
    Thanked 33 Times in 22 Posts
    Looks like you missed a </div> tag on the tag before the </body> tag.
    1994 Mariana Blue Pearl Mitsubishi 3000GT VR-4
    DR-650s and supporting, PST CFDS, Volk GT-Cs, Tein Flex, among other things

    Feb. 06 3SI ROTM - Best AWD BRG 07 - 3rd Place 2G 07 3/S National Gathering - People's Choice BRG 08
    BRG 2011 Total Package - NG11 Car Show 1st Place

    2010 Space Gray E90 335i M-Sport 6MT - 400whp/450wtq
    2002 Jet Black E53 X5 4.4i AWD - Bavarian Workhorse

  3. #3
    Administrator Alan92RTTT's Avatar
    Join Date
    Jul 2010
    Owner Since
    02/1998

    Location
    Madison Heights, Mi
    Posts
    2,958
    Blog Entries
    7
    Thanks
    16
    Thanked 675 Times in 255 Posts
    Fixed the div tag, no change.

    If it helps in FF the spinner on the tab keeps spinning.

    I've got to get some nocache headers in it. It runs once, fails and I can't open fire bug on it and get it to rereun without closing the tab and entering it from the address bar(no shift-refresh does not work)

  4. #4
    Administrator Alan92RTTT's Avatar
    Join Date
    Jul 2010
    Owner Since
    02/1998

    Location
    Madison Heights, Mi
    Posts
    2,958
    Blog Entries
    7
    Thanks
    16
    Thanked 675 Times in 255 Posts
    uploaded here if anyone wants to look

    http://3sg.org/beta/3sg_footer.htm

  5. #5
    3SWiki.org
    Join Date
    Sep 2010
    Owner Since
    10+ Years

    Location
    The Silver State
    Posts
    661
    Thanks
    73
    Thanked 94 Times in 53 Posts
    Give this a try:

    PHP Code:
    <head>
        <
    style>
        
    div.div_3sg
        
    {
            
    width100%;
        }
        
    div.tab_3sg
        
    {
            
    border1px solid;
            
    marginauto;
            
    clearboth;
            
    height120px;
            
    width98%;
            
    padding-left4px;
        
        }
        
    #tabs li {
            
    list-stylenone outside none;
        }
        
    #tabs ul {
            
    padding0;
            
    border-bottom0 none !important;
        }
        
        
    #tabs li, #tabs li a {
            
    floatleft;
        }
        
    #tabs ul li{
            
    font-weightbold;
            
    padding8px;
            
    text-decorationnone;
            
    cursorpointer;
        }
        </
    style>
      <
    script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    </head>
    <body>
    <div id="tabs" class="div_3sg">
        <div id="tabHeader" style="display:block; float:left;">
            <!-- Tabs Generated Here -->
        </div>
    </div>


    <script>
    $.getJSON('3sgTabs.json', function(data) {
        var items = [];

        $.each(data.groups, function(id, group) {
            items.push('<li id="tab-' + (id+1) + '">' + group.name + '</li>');
        });
        
        $('<ul/>', {
            'class': 'tabCategories',
            html: items.join('')
        }).appendTo('#tabHeader');
    });
    </script>

    </body> 
    Output generated is:

    PHP Code:
    <div id="tabs" class="div_3sg">
        <
    div id="tabHeader" style="display:block; float:left;">
            <
    ul class="tabCategories">
                <
    li id="tab-1">Events</li>
                <
    li id="tab-2">Groups</li>
                <
    li id="tab-3">Information</li>
            </
    ul>
        </
    div>
    </
    div
    Working demo:

    http://www.stealthify.com/3sgto/projects/3sgTabs.php

  6. #6
    Administrator Alan92RTTT's Avatar
    Join Date
    Jul 2010
    Owner Since
    02/1998

    Location
    Madison Heights, Mi
    Posts
    2,958
    Blog Entries
    7
    Thanks
    16
    Thanked 675 Times in 255 Posts
    Can you explain why what I did , did what it did?

  7. #7
    3SWiki.org
    Join Date
    Sep 2010
    Owner Since
    10+ Years

    Location
    The Silver State
    Posts
    661
    Thanks
    73
    Thanked 94 Times in 53 Posts
    I didn't look too far into it. I just recreated it from scratch with how I would do it, and then adapted it to what you were trying to accomplish.

    Looking at it a little closer now, your problem line is using document.writeln to begin writing to the document and then not using the document.close() method to close the output stream.

  8. #8
    Administrator Alan92RTTT's Avatar
    Join Date
    Jul 2010
    Owner Since
    02/1998

    Location
    Madison Heights, Mi
    Posts
    2,958
    Blog Entries
    7
    Thanks
    16
    Thanked 675 Times in 255 Posts
    I originally used document.write() would that still need the close?

  9. #9
    3SWiki.org
    Join Date
    Sep 2010
    Owner Since
    10+ Years

    Location
    The Silver State
    Posts
    661
    Thanks
    73
    Thanked 94 Times in 53 Posts
    Yep, that's pretty much identical to .writeln, except .writeln will put a new line after it. Both open and write to the output stream.

    Once all the writes are performed, the document.close() method causes any output written to the output stream to be displayed.

  10. #10
    Administrator Alan92RTTT's Avatar
    Join Date
    Jul 2010
    Owner Since
    02/1998

    Location
    Madison Heights, Mi
    Posts
    2,958
    Blog Entries
    7
    Thanks
    16
    Thanked 675 Times in 255 Posts
    wonder if thats what broke it.

    I'll have to try it at lunch

    I'll probably use yours tho I like it better.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
The 3000GT/Stealth/GTO Web History Project
3000gt.com
3000GT / Stealth International WWWboard Archive
Jim's (RED3KGT) Reststop
3000GT/Stealth/GTO Information and Resources
Team 3S
3000GT / Stealth / GTO Information
daveblack.net
3000GT/Stealth/GTO Clubs and Groups
Michigan 3S
MInnesota 3S
Wisconsin 3S
Iowa, Nebraska, Kansas 3S
North California 3000GT/Stealth
United Society of 3S Owners
3000GT/Stealth/GTO Forums
3000GT/Stealth International
3000GT/Stealth/GTO Event Pages
3S National Gathering
East Coast Gathering
Upper Mid-West Gathering
Blue Ridge Gathering