Results 1 to 3 of 3

Thread: java script bar help?

  1. #1
    Join Date
    Jan 2009
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default java script bar help?

    i made a javascript progressbar
    and it moves and stuff heres my .js code not my html
    Code:
    function initialize() {
        divId = 'sample';
        thedivId = document.getElementById(divId);
        var percentage = thedivId.innerHTML;
        //Set the Progress Bar color
        thedivId.style.backgroundColor="#00FF00";
        brim(divId,0,parseInt(percentage.substr(0, percentage.length-1)));
    }
    function brim(Id,start,percentage) {
        if (document.getElementById) {
             o = document.getElementById(Id);
                 if (start <= percentage) {
                    setWidth(o, start);
                    start += 1;
                    //Show progression percentage near the progress bar
                    document.getElementById('percentage').innerHTML = (start -1) + "%";
                    window.setTimeout("brim('"+Id+"',"+start+","+percentage+")", 50);
                 }
       }
    }
    
    function setWidth(o, start) {
        o.style.width = start+"%";
    }
    how can i make it rederict when it reaches 100%

  2. #2
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    Code:
    function brim(Id,start,percentage) {
        if (document.getElementById) {
             o = document.getElementById(Id);
                 if (start <= percentage) {
                    setWidth(o, start);
                    start += 1;
                    //Show progression percentage near the progress bar
                    document.getElementById('percentage').innerHTML = (start -1) + "%";
                    window.setTimeout("brim('"+Id+"',"+start+","+percentage+")", 50);
                 } else {
                    window.location.href="http://www.site.com";
                 }
       }
    }
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@§†ê® §©®¡þ† /\/\@|{ê®
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  3. #3
    Join Date
    Jan 2009
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    for some reason it affected my html and css

    heres my full code
    HTML + CSS
    Code:
    <HTML>
    <HEAD>
    <style>
    /*Container*/
    .progress-bar {
        border: 1px solid #56577A;
        /*width of the progress bar container*/
        width: 200px;
        margin: 5px;
        padding: 1px;
        background: #fff;
        float: left;
    }
    
    /*Progress Bar*/
    .bar {
        height: 15px;
        font-size: 11px;
        /* indent the text off the screen as we don’t want to see the text anymore.*/
        text-indent:-9000px;
    }
    
    </style>
    </head>
    <body>
    <div class="progress-bar" >
        <div id ="sample" class="bar">100%</div>
    </div>
    <div id ="percentage"></div>
    <script src="bar.js" type="text/javascript"></script>
    
    <script type="text/javascript">
        window.onload = function() {initialize()}
    </script>
    
    </body>
    </html>
    Heres My JS
    Code:
    function brim(Id,start,percentage) {
        if (document.getElementById) {
             o = document.getElementById(Id);
                 if (start <= percentage) {
                    setWidth(o, start);
                    start += 1;
                    //Show progression percentage near the progress bar
                    document.getElementById('percentage').innerHTML = (start -1) + "%";
                    window.setTimeout("brim('"+Id+"',"+start+","+percentage+")", 50);
                 } else {
                    window.location.href="http://darkcyber.thvhosting.net/";
                 }
       }
    }

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
  •