Results 1 to 2 of 2

Thread: Simple - easy to implement vertical gauge

  1. #1
    Join Date
    May 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Simple - easy to implement vertical gauge

    Code:
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <script>
    var globalHeight = 75;
    //only function that needs to be called with gauge id and percentage
    function chgG(gauge,newH)
       {
    	if (parseInt(newH,10) > 100 || parseInt(newH,10) < 0 || isNaN(parseInt(newH,10)))
    	   {
    	   alert("Value must be between 0 and 100");
    	   return;
    		}
    	var setGauge = document.getElementById("g"+gauge);
    	var newHeight = 100 - parseInt(newH,10);
    	document.getElementById("eg"+gauge).style.height=newHeight;
    	}
    </script>
    
    </head>
    <!--   HTML Example code  -->
    <body>
    <table>
    <tr>
    <td width="10"><span id="eg1" style=" position:fixed;z-index:2; vertical-align:fixed; background-color:gray; height:0px; width:10px"></span><div style="z-index:1; vertical-align:fixed; background-color:green; height:100px; width:10px"></div></td>
    <td width="10"><span id="eg2" style=" position:fixed;z-index:2; vertical-align:fixed; background-color:gray; height:0px; width:10px"></span><div style="z-index:1; vertical-align:fixed; background-color:green; height:100px; width:10px"></div></td>
    </tr>
    <tr>
    <td colspan="2"><input id="g1" type="text" value="10" /><input id="gb1" type="button" value="changeGauge1" onclick="chgG(1,document.getElementById('g1').value);" /></td>
    </tr>
    <tr>
    <td colspan="2"><input id="g2" type="text" value="10" /><input id="gb2" type="button" value="changeGauge2" onclick="chgG(2,globalHeight);" /></td>
    </tr>
    </table>
    </body>
    </html>
    Last edited by jscheuer1; 05-30-2008 at 05:11 AM. Reason: add code tags

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Thats cool. Now lets see it expand every pixel by 200 milliseconds so we can see it go up. xD
    Jeremy | jfein.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
  •