Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
I don't "get" this error!
Old 03-29-2009, 01:34 PM I don't "get" this error!
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
This is my code, the part in red creates the error:

Code:
 
$SQL = "Select * From clients";
$Columns = mysql_query("Show Columns From Clients");
$Values = mysql_query("Select * From Clients");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<script type="text/javascript"
 src="http://api.maps.yahoo.com/ajaxymap?v...RUy59b2rTvXmGA">  
</script>
<script type="text/javascript">
var ReqStr;
var Rec=0;
function Initialize()
 {
  alert("Initialize");
  <?php
  if (mysql_num_rows($Columns) > 0)
   {
    $i = 0;
    $c = 0;
    $Var = array();
    $Col = 0;
    echo "\r";
    while ($Title = mysql_fetch_assoc($Columns))
     {
     echo "var ".$Title[Field]." = new Array();\n";
     $Var[$i] = "$Title[Field]";
     $i = $i+1;
     }
    echo "\n";
    while ($Data = mysql_fetch_array($Values))
     {
      while ($Col < $Columns)
       {
        while ($c < $i)
         { 
          echo $Var[$c]."[".$Col."] = '".$Data[$c]."'\n";
          $c = $c+1;
         }
        $Col = $Col+1;
       }
     }
   } 
  ?>
  SetValues();
 }
 
function SetValues()
 {
  alert("SetValues");
  document.getElementById("StoreName").value = StoreName[Rec];
document.getElementById("Address").value = Address[Rec];
document.getElementById("City").value = City[Rec];
document.getElementById("ST").value = ST[Rec];
document.getElementById("Zip").value = Zip[Rec];
document.getElementById("Phone").value = Phone[Rec];
document.getElementById("Ext").value = Ext[Rec];
document.getElementById("Cell").value = Cell[Rec];
document.getElementById("Manager").value = Manager[Rec];
document.getElementById("Notes").value = Notes[Rec];
GetMap();
 }
 
function GetMap()
 { 
  alert("GetMap");
  var Location =  document.getElementById("Address").value + " " + document.getElementById("City").value + "," + document.getElementById("ST").value;
  if(Location)
   {
    // Create a map object   
    var map = new YMap(document.getElementById('map'));   
 
    // Add map zoom (long) control   
    map.addZoomLong();   
 
    // Add the Pan Control   
    map.addPanControl();   
    // Add map type control   
    map.addTypeControl();
 
    //Add marker
    map.addMarker(Location);
 
    // Set map type to either of: YAHOO_MAP_SAT, YAHOO_MAP_HYB, YAHOO_MAP_REG   
    map.setMapType(YAHOO_MAP_REG);   
 
    // Display the map centered on a geocoded location   
    map.drawZoomAndCenter(Location, 3);
   }    
 }
</script> 
<style type="text/css">  
#map{
 border: thin solid #aaaaaa;
 width: 300px;
 display: block;
 overflow: hidden;
 height: 300px;
} 
    .style1 {
 color: #FF0000;
 font-weight: bold;
 font-style: italic;
}
    #main {
}
    .style2 {
 font-size: large;
 font-weight: bold;
 font-style: italic;
}
    .style3 {color: #FFFFCC}
    #main #form {
 width: 0px;
 border-style: inset;
 text-align: center;
 background-attachment: fixed;
}
    .style4 {font-size: large}
    #main #controls {
 border-top-width: thin;
 border-right-width: thin;
 border-bottom-width: thin;
 border-left-width: thin;
 border-top-style: outset;
 border-right-style: outset;
 border-bottom-style: outset;
 border-left-style: outset;
 width: 0px;
}
body {
 background-repeat: repeat;
 background-image: url(../Images/logo.png);
}
.style6 {
 font-family: "Century Gothic";
 font-weight: bold;
 font-style: italic;
 font-size: xx-large;
}
.style8 {font-size: small}
</style> 
</head>
<body onLoad="Initialize()">
  <div id="main" align="center"><span class="style6">Hawks</span>
  <form name="Clients" action="">
  <p>&nbsp;</p>
  <p><span class="style2">Clients</span></p>
  <div id="form" align="center">
   <table border="0" cellspacing="1"  bgcolor="#00FFFF">
    <tr>
     <td  nowrap colspan="2" align="left"><div align="left" class="style1">
       <div align="center" class="style4"><?php echo urldecode($ClientID) ?>
         <div class="style8"><strong> Last Visit: </strong>03/20/09</div>
       </div>
     </div></td>
     <td rowspan="9"><div id="map" align="center"></div></td>
    </tr>
    <tr>
     <td  nowrap align="left"><strong>Store Name: </strong></td>
     <td  nowrap align="right"><div align="left">
       <input size="32" type="text" id="StoreName" name="StoreName" value="">
     </div></td>
    </tr>
    <tr>
     <td nowrap align="left"><strong>Address:</strong></td>
     <td nowrap align="right"><div align="left">
       <input size="32" type="text" id="Address" name="Address" value="" onKeyup="GetMap()">
     </div></td>
    </tr>
    <tr>
     <td nowrap align="left"><strong>City:</strong></td>
     <td align="right" nowrap><div align="left">
       <input size="13" type="text" id="City" name="City" onKeyup="GetMap()" value="" maxlength="32">
       <input size="1" type="text" id="ST" name="ST" maxlength="2" onKeyUp="GetMap()" value="">
       <input size="5" type="text" id="Zip" name="Zip" value="">
     </div></td>
    </tr>
    <tr>      </tr>
    <tr>
     <td nowrap align="left"><strong>Manager(s):</strong></td>
     <td nowrap align="right"><div align="left">
       <input size="32" type="text" id="Manager" name="Manager" value="">
     </div></td>
    </tr>
    <tr>
     <td nowrap align="left"><strong>Phone:</strong></td>
     <td nowrap><div align="left">
       <input size="14" type="text" id="Phone" name="Phone" value="">
       <strong>Ext:</strong>
      <input size="6" type="text" id="Ext" name="Ext" value="">
     </div></td>
    </tr>
    <tr>
     <td nowrap align="left"><strong>Cell / Other:</strong></td>
     <td nowrap><div align="left">
       <input size="32" type="text" id="Cell" name="Cell" value="">
     </div></td>
    </tr>
    <tr>
     <td colspan="2" align="left" nowrap><div align="center"><strong>Notes:</strong>
     </div>
      <div align="center">         
       <textarea id="Notes" name="Notes" rows="3" cols="32"></textarea>
     </div></td>
    </tr>
   </table>
  </div>
  <div id="Message"></div>
  <div align="center">
  <div id="controls">
   <table border="1" cellpadding="2" cellspacing="3">
    <td nowrap height="39" bgcolor="#00FF00">
       <input title="First Record" type="button" value="|<" name="First" onClick="Handler(this.name,''">
       <input title="Previous Record" type="button" value="<" name="Previous" onClick="Handler(this.name,'')">
       <input title="Next Record" type="button" value=">" name="Next" onClick="Handler(this.name,'')">
       <input title="Last Record" type="button" value=">|" name="Last" onClick="Handler(this.name,'')">  </td>
    <td nowrap bgcolor="#00FF00">
       <input title="New Record" type="button" value="*" name="New" onClick="Handler(this.name,'')">
       <input title="Sort by current field" type="button" value="!" id="Sort" name="Sort" onClick="Handler(this.name,'')">  </td>
    <td nowrap bgcolor="#FF0000" class="style3">
       <input title="Save Record" type="button" value="Save" name="Save" onClick="Handler(this.name,'')">
       <input title="Delete Record" type="button" value="Delete" name="Delete" onClick="Handler(this.name,'')">  </td>
    <td nowrap bgcolor="#CCCCCC" class="style3">
       <input title="Return to Main Menu" type="button" value="Done" name="Done" onClick="Handler(this.name,'')">
       <input title="Clear Form" type="button" value="Clear" name="Clear" onClick="Handler(this.name,'')">  </td>
   </table>
   </div>
   </div>
  </form>
</div>
</body>
</html>
error is (firefox error console) "Warning: Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead.
Source File: http://127.0.0.1/Hawks/Clients/Clients.php
Line: 44

this error is generated for all lines in red.

Anybody know what's up?
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-29-2009, 02:30 PM Re: I don't "get" this error!
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Where are the arrays
StoreName[]
and
Address[]
being initialized? I don't see them anywhere that would give your function global access to them. The link you gave to the page isn't working for me.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 03-29-2009, 03:10 PM Re: I don't "get" this error!
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
that's because the link is to 'localhost'
127.0.0.1 is always your machine.

Though, I would guess the problem is, he's trying to reference items in the page before the page exists.

Try moving the javascript to the bottom of the page
__________________

Please login or register to view this content. Registration is FREE


Last edited by willcode4beer; 03-29-2009 at 03:11 PM..
willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 03-29-2009, 03:26 PM Re: I don't "get" this error!
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
Yeah, sorry the link was placed by error console, this is an intranet. script is a function that executes after the page has loaded... I'm not syaing your wrong, but how would moving script to bottom of body fix it? Ah is it possible that FF is executing the scripts before page loads ala IE4 and Netscape? Bad, very bad! yup, just checked, IE does not error, FF just updated. Hmm...
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!

Last edited by Sleeping Troll; 03-29-2009 at 03:34 PM..
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Old 03-29-2009, 03:33 PM Re: I don't "get" this error!
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
it's going to work from the top-down. It's supposed to.
How else would document.write() ever work?
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 03-29-2009, 03:35 PM Re: I don't "get" this error!
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Quote:
how would moving script to bottom of body fix it?
That wouldn't matter.

What I'm seeing is that there are some arrays being created inside of the Initialize() function, which means they're local to that function. I can't tell for sure because I don't know the output from your database. If StoreName[], etc are being created there with the var keyword, they are local to that function and outside of the scope of the SetValues() function.

I think there is a proprietary method in IE of accessing items by ID or name through global array names, which is why it is kicking up this strange error. What is really happening is undefined variables because of scope issues.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 03-29-2009, 04:16 PM Re: I don't "get" this error!
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
I think you are exactly right, I need to define the vars outside of function.
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Old 03-29-2009, 04:24 PM Re: I don't "get" this error!
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
Duh... yup that did it! good eyes btw! Is there anything that can be done about this spammer!
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!

Last edited by Sleeping Troll; 03-29-2009 at 05:13 PM..
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to I don't "get" this error!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21162 seconds with 12 queries