Current location: Hot Scripts Forums » General Web Coding » JavaScript » What this error mean ?


What this error mean ?

Reply
  #1 (permalink)  
Old 10-09-06, 12:48 PM
zoliky's Avatar
zoliky zoliky is offline
Aspiring Coder
 
Join Date: Jun 2006
Posts: 537
Thanks: 0
Thanked 0 Times in 0 Posts
What this error mean ?

Hello
What mean this JavaScript error ?

Quote:
Error: ylib_getObj("fileInput" + nextHiddenIndex) has no properties
Source File: http://sendmsgu2.php?do=attach&more
Line: 22
I have the following source code:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="content-type"content="text/html; charset=iso-8859-1" />
  <title>Send Message</title>
  <script>
  function ylib_getObj(id,d)
  {
  	var i,x;  if(!d) d=document;
  	if(!(x=d[id])&&d.all) x=d.all[id];
  	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][id];
  	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=ylib_getObj(id,d.layers[i].document);
  	if(!x && document.getElementById) x=document.getElementById(id);
  	return x;
  }

  var nextHiddenIndex = 5;

  function AddFileInput()
  {
  	ylib_getObj("fileInput" + nextHiddenIndex).style.display = document.all ? "block" : "table-row";
  	nextHiddenIndex++;
  	if(nextHiddenIndex >= 10) ylib_getObj("attachMoreLink").style.display = "none";
  }

  function AttachMoreFiles()
  {
  	var theForm = document.getElementById( "attachform" );
  	theForm.action = "?do=attach&more";
  	theForm.submit();
  	
/*	document.foo.action = "?do=attach&more";
  	document.foo.submit();*/
  }

  function Attach()
  {
  	document.foo.action = "?do=attach";
  	document.foo.submit();
  }

  function Remove(msg)
  {
  	document.foo.action = "?do=attach&unattach=" + msg;
  	document.foo.submit();
  }
  </script>
  <style type="text/css">
  <!--
	.add, .remove
	{
		color: #0000FF;
		cursor: pointer;
		text-decoration: underline;
	}
	.remove
	{
		font-size: 75%;
	}
   -->
   </style>
</head>
<body>

<table cellspacing="0" border="0">
<tr>
<td width="150" valign="top" bgcolor="#FFFFFF">
<table cellspacing="0" border="0">
  <!-- Menu -->
  <tr><td width="150" bgcolor="#AEADB7"><b>Mesaje</b></td></tr>
  <tr><td width="150" bgcolor="#D0D0D9"><a href="privmsg.php?foldername=inbox">Inbox</a></td></tr>
  <tr><td width="150" bgcolor="#D0D0D9"><a href="privmsg.php?foldername=sent">Sent</a></td></tr>
  <tr><td width="150" bgcolor="#D0D0D9"><a href="privmsg.php?foldername=draft">Draft</a></td></tr>

  <tr><td width="150" bgcolor="#D0D0D9"><a href="privmsg.php?foldername=trash">Trash</a></td></tr>
  <tr><td width="150" bgcolor="#D0D0D9"><a href="sendmsgu2.php">Compose</a></td></tr>
  <!-- Menu 2 -->
  <tr><td width="150" bgcolor="#AEADB7"><b>Cont</b></td></tr>
  <tr><td bgcolor="#D0D0D9"><a href="ignore.php">Ignore users</a></td></tr>
  <tr><td bgcolor="#D0D0D9"><a href="address.php">Address book</a></td></tr>

  <tr><td bgcolor="#D0D0D9"><a href="editu.php">User Data</a></td></tr>
  <tr><td bgcolor="#D0D0D9"><a href="logout.php">Logout</a></td></tr>
</table>
</td>

<td width="10" bgcolor="#FFFFFF">
</td>

<td width="750" valign="top" bgcolor="#FFFFFF">
<form name="foo" id="attachform" action="sendmsgu2.php?do=attach" method="post" enctype="multipart/form-data">
<input type="hidden" name="msgid" value="111">
<input type="hidden" name="list" value="0">

Clic pe "Browse" pentru a selecta un fisier
<table cellpadding="4" cellspacing="0" border="0">
<tr valign="top" ><td><b>File 1:</b></td>
<td align="left">
<img src="images/clip_1.gif" border="0" alt="image">New Text Document.txt [<a href="javascript:Remove(136)">Remove</a>]
</td>
</tr>
<td><b>File 2:</b></td>
<td align="left">
<img src="images/clip_1.gif" border="0" alt="image">New Text Document.txt [<a href="javascript:Remove(137)">Remove</a>]
</td>

</tr>
<td><b>File 3:</b></td>
<td align="left">
<img src="images/clip_1.gif" border="0" alt="image">New Text Document.txt [<a href="javascript:Remove(138)">Remove</a>]
</td>
</tr>
<td><b>File 4:</b></td>
<td align="left">
<img src="images/clip_1.gif" border="0" alt="image">New Text Document.txt [<a href="javascript:Remove(139)">Remove</a>]
</td>
</tr>

<td><b>File 5:</b></td>
<td align="left">
<img src="images/clip_1.gif" border="0" alt="image">New Text Document.txt [<a href="javascript:Remove(140)">Remove</a>]
</td>
</tr>
<td><b>File 6:</b></td>
<td align="left">
<img src="images/clip_1.gif" border="0" alt="image">New Text Document.txt [<a href="javascript:Remove(141)">Remove</a>]
</td>
</tr>
  

<tr>
<td colspan="2">

<table style="margin:1em 0 1em 0">

<tr valing="top" id="fileInput6" style="display:none" >
<td><b>File 7:</b></td>
<td><input type="file" name="userFile6" size=20 onkeypress="KeyPress()"  ></td>
</tr>
<tr valing="top" id="fileInput7" style="display:none" >
<td><b>File 8:</b></td>
<td><input type="file" name="userFile7" size=20 onkeypress="KeyPress()"  ></td>
</tr>
<tr valing="top" id="fileInput8" style="display:none" >
<td><b>File 9:</b></td>

<td><input type="file" name="userFile8" size=20 onkeypress="KeyPress()"  ></td>
</tr>
<tr valing="top" id="fileInput9" style="display:none" >
<td><b>File 10:</b></td>
<td><input type="file" name="userFile9" size=20 onkeypress="KeyPress()"  ></td>
</tr>

</table>

<p id="attachMoreLink"><a href="javascript:AddFileInput()">Attach More Files</a></p>
<input type="submit" name="ataseaza" value="Ataseaza">


</form>	
</body>

</html>
I get this error whe I click on <p id="attachMoreLink"><a href="javascript:AddFileInput()">Attach More Files</a></p>

Anyone help me to explain what is the problem ?
Please!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-10-06, 07:19 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
nextHiddenIndex is set to 5 in the beginning, making the script look for an element with the id "fileInput5", which doesn't exist.
The ylib_getObj function does not return an object in that case, and that's why you get the "has no properties" error.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 10:15 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.