Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

incredible ? a alert() fixes my bug !?

Status
Not open for further replies.

EliseD

Programmer
Jun 22, 2004
12
FR
Hi all,

I have a code that makes a loop into the row of my table, and adds en event for each row.
when I add an : alert("foo")

into my loop, the code works, for all 166 rows

when i remove the alert, the code is executed but not until the end of all rows, only a part of the rows (like 88/165). it seems really strange no ?

here is the exemple :

doesn't find and process all rows :
Code:
for(i=1;i<theTab.rows.length;i++)      
{                                     
	theTab.rows[i].onmousedown=function(event){detectClick(event, this)}; 
	//alert("foo");
}
alert(i);


find and process all rows :
Code:
for(i=1;i<theTab.rows.length;i++)      
{                                     
	theTab.rows[i].onmousedown=function(event){detectClick(event, this)}; 
	alert("foo");
}
alert(i);

I really don't understand. the particularity of my table is that it's filled with DOMXML and it's not a fixed table.

Any idea ?

Regards,


Elise
 
i perform this function at the end of the onload, that's the very last line of the body onload
 
here is my code (I removed code that is not directly impacted by my problem) :
Code:
<HTML>
<BODY id="body" style="BEHAVIOR: url(webservice.htc)" onload="initWebservices();DoMyLookup();return false;">
<form name="Form1" meTHod="post" id="Form1">
<script>
.....
function DoMyLookup() 
{
  	window.status = "waiting....";
	//some code to load the data from a WebServiceand get the result
	if (!result.error) 
	{
 		// stuff the result into an XML Document
  		document.all.XMLDataCases.loadXML(result.value);
  		window.status = "waiting..........";
  		setMouse('DataIslandGrid1');  	   
	}
 	window.status = "waiting............";
}

function setMouse(tabID)
{
	THeTab = document.getElementById(tabID);                                        
	oLasTRow = THeTab.rows[0];                                                      
	THeTab.style.cursor = 'default';                                               
	THeTab.onselectstart = function(){return false};   
	alert("data loaded");                           
	for(i=1;i<THeTab.rows.lengTH;i++)      
	{                                     
		THeTab.rows[i].onmousedown=function(event){detectClick(event, THis)}; 
	}
	alert(i);
						  
	window.status = "data loaded !";
}  

</script>
<XML id="XMLDataCases" />

<XML id="xslDataIslandGrid1">
	<NewDataSet>
		<xsl:for-each order-by="?" select="TABLE" XMLns:xsl="[URL unfurl="true"]http://www.w3.org/TR/WD-xsl">[/URL]
			<TABLE ID="TABLE1">
				<CaseNum>
					<xsl:value-of select="CaseNum" />
				</CaseNum>
				<CaseRef>
					<xsl:value-of select="CaseRef" />
				</CaseRef>
				<CreationDate>
					<xsl:value-of select="Creation_Date" />
				</CreationDate>
				<Description>
					<xsl:value-of select="Description" />
				</Description>
				<Entity>
					<xsl:value-of select="Entity" />
				</Entity>
			</TABLE>
		</xsl:for-each>
	</NewDataSet>
</XML>
			
<TABLE datasrc="#XMLDataCases" id="DataIslandGrid1" class="clsTest" >
	<THEAD>
		<TR>
			<TH widTH="120">
				<a href="javascript:sortColumn(XMLDataCases.XMLDocument, xslDataIslandGrid1.XMLDocument, '+CaseNum');">
					Case Num</a></TH>
			<TH widTH="190">
				<a href="javascript:sortColumn(XMLDataCases.XMLDocument, xslDataIslandGrid1.XMLDocument, '+CaseRef');">
					Case Reference</a></TH>
			<TH widTH="180">
				<a href="javascript:sortColumn(XMLDataCases.XMLDocument, xslDataIslandGrid1.XMLDocument, '+Creation_Date');">
					Creation Date</a></TH>
			<TH widTH="250">
				<a href="javascript:sortColumn(XMLDataCases.XMLDocument, xslDataIslandGrid1.XMLDocument, '+Description');">
					Description</a></TH>
			<TH widTH="80">
				<a href="javascript:sortColumn(XMLDataCases.XMLDocument, xslDataIslandGrid1.XMLDocument, '+Entity');">
					Label</a></TH>
		</TR>
	</THEAD>
	<tbody>
		<TR ondblclick="double();">
			<TD class align="center"><div dataFld="CaseNum">
				</div>
			</TD>
			<TD class align="center"><div dataFld="CaseRef">
				</div>
			</TD>
			<TD class align="center"><div dataFld="Creation_Date">
				</div>
			</TD>
			<TD class><div dataFld="Description">
				</div>
			</TD>
			<TD class align="center"><div dataFld="Entity">
				</div>
			</TD>
		</TR>
	</tbody>
</TABLE>

</BODY>
</HTML>
 
It looks like someone did mass search & replace (all th/tr in code are uppercased) - and some property names are affected too (length became lengTH).
 
yes i know i did a search and replace before to post my code in order to have uppercased HTML tags ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top