Jump to content

[SOLVED] javascript that little bugger!


mforan

Recommended Posts

<html>
<head>
<title>HQ</title>
<link href="defaults.css" rel="StyleSheet" type="text/css">
</head>
<body bgcolor="#000000">
<center>

</center>
<script type="text/javascript">
var currenttime = 'January 12, 2009 00:27:10' //get date
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var serverdate=new Date(currenttime)

function padlength(what){
var output=(what.toString().length==1)? "0"+what : what
return output
}

function displaytime(){
serverdate.setSeconds(serverdate.getSeconds()+1)
var timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds())
document.getElementById("servertime").innerHTML=timestring
}

window.onload=function(){
setInterval("displaytime()", 1000)
}
</script>

<center>
  <table class="metal" cellpadding="3" cellspacing="3">
    <tr align="center">

      <td width="55" class="head"> Money  </td>
      <td width="43" class="head"> Land  </td>
      <td width="54" class="head"> People  </td>
      <td width="41" class="head"> Pop.  </td>
      <td width="57" class="head"> Income  </td>
      <td width="70" class="head"> Networth  </td>

      <td class="head"> Time  </td>
    </tr>
    <tr align="center" valign="top">
      <td class="variable"><a class="noline">£7000</a></td>
      <td class="variable"><a class="noline">200<br>
        acres</a></td>
      <td class="variable"><a class="noline">1800</a></td>

      <td class="variable"><a class="noline">100%</a></td>
      <td class="variable"><a class="noline">£13500<br />
      per hour </a></td>
      <td class="variable"><a class="noline">4</a></td>
      <td width="66" class="variable"><a class="noline"><span id="servertime"></span></a></td>
    </tr>
  </table>

  <br>
  <table border="0" cellpadding="3" cellspacing="2" width="75%">
    <tr align="center">




            <td width="25%"></td>
            <td width="25%"></td>
        <td width="25%"></td>
  </table>
  </center>
<br>

<br>
<br>

<center>
<table width="90%" border="0" cellpadding="0" cellspacing="0">
<tr>
      <td colspan="2"><table width="100%" cellpadding="3" cellspacing="3" class="metal">
          <tr>
          <td class="head"><center>
              <font size="6"><b>Alliances</b></font>
            </center></td>

        </tr>
        </table></td>
    </tr>
<td colspan="1" width="67%" valign="top"><div align="center"><br>
      <br>
    </div>
    <center>
      <div align="center">Welcome <a class="noline">Private Decapitator</a>.<br>

        If you need to see who's in who's alliance, you've come to the right place. Check your own and other alliances!<br>
        <br>
      </div>
      <table width="80%" class="metal" cellpadding="3" cellspacing="3">
        <form action="alllog.php" method="post">
          <tr>
            <td class="head" colspan="2">Search For User</td>
          </tr>

          <tr valign="center">
            <td class="variable" colspan="1" width="50%" align="right"><input type="text" name="alliance" size="15" maxlength="25" class="text">
              <input type="hidden" name="search" value="1">
            </td>
            <td class="variable" width="50%" colspan="1" align="left"><select name="rankt">
                <option value="%">Any Status</option>
                <option value="Private">Private</option>
                <option value="Captain">Captain</option>

                <option value="Major">Major</option>
                <option value="Lt Colonel">Lt Colonel</option>
                <option value="Colonel">Colonel</option>
                <option value="Major General">Major General</option>
                <option value="Lt General">Lt General</option>
                <option value="General">General</option>

              </select>
              <input type="submit" value="Search" class="submit"></td>
          </tr>
        </form>
                <tr>
          <td class="head" colspan="2"><font size="4"><b>1 - 1 (1) of users containing ""</b>
            </th>
        </tr>

        <tr>
          <td class="variable" colspan="2" align="center"><b><br>
            <center>
            <table id="tablem" class="metal" cellpadding="3" cellspacing="3" width="100%">
              <tr>
                <td class="head"> Name
                  </th>
                <td class="head">Land
                  </th>

                <td class="head">Networth
                  </th>
                <td class="head">Status
                  </th>
              </tr>
              <tr bgcolor='33333C'><td align=center><a href='browse.php?name=Decapitator'><font color=#ffea00>Decapitator</font></a></td><td align=center>200</td><td align=center>4</td><td align=center>Private  <img src='/game/images/ranks/sprivate.jpg' align='absmiddle'></td></tr>                  </table>
                  <br>

                  <font color="#ffea00">Yellow</font> means that user is online<br>
                  <br>
                  <font color="#00CCCC">Turquoise</font> means that user is protected<br>
                  <br>
                  <font color="#FF0000">Red</font> means that user is a premium member<br>

                  </b></td>
              </tr>
            </table>

		</td>
        </tr>
      </table>
      <br>
          </center>
</body>

    </html>
<script type="text/javascript">
      window.onload = function(){
        ConvertRowsToLinks("tablem");
      }
      
      function ConvertRowsToLinks(xTableId){

        var rows = document.getElementById(xTableId).getElementsByTagName("tr");
   
        for(i=0;i<rows.length;i++){
          var link = rows[i].getElementsByTagName("a")
          if(link.length == 1){
            rows[i].onclick = new Function("document.location.href='" + link[0].href + "'");
            rows[i].onmouseover = new Function("this.className='highlight'");
            rows[i].onmouseout = new Function("this.className=''");
          }
        }

      }

    </script>

 

how comes the top most java script doesnt display the data on the site? any ideas anyone?

Link to comment
Share on other sites

Although there are a lot of things I would change in that functionality, your problem has to do with your declaration of window.onload.

 

You define two different functions for window.onload

window.onload=function(){
setInterval("displaytime()", 1000)
}

      window.onload = function(){
        ConvertRowsToLinks("tablem");
      }

The second will overwrite the first. You need to define both within window.onload:

window.onload=function()
{
    ConvertRowsToLinks("tablem");
    setInterval("displaytime()", 1000)
}

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.