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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with getElementById in IE 1

Status
Not open for further replies.

mcowen

Programmer
Oct 21, 2001
134
GB
Hi,

I have a XSL page with 3 tables and each table has a tbody element. When the page loads XML data is parsed into js objects. Once that is done I use DOM functions to add the data to the correct tables...well thats how its supposed to work. When I create the row using a createRow function i have written the first thing I do is acquire a handle to the table (its id is a parameter passed in) but this is where things get strange in IE. It finds the first tbody and adds the rows correctly but when it comes to the trying to find the 2nd tbody it falls over. I've tried getElementById, getElementsByTagName and getElementsByName but only 1 tbody is ever found.

My xsl page...
Code:
<table width="600" border="0" cellpadding="0" cellspacing="0">
  <tbody id="mainbodypi" name="mainbodypi">
  <tr>
    <td width="284" height="19" valign="top">Case description </td>
    <td width="122" valign="top">Date opened </td>
    <td width="122" valign="top">Case code </td>
  </tr>
  	<script type="text/javascript">
  		<xsl:for-each select="CASE">
		
		xmlresults[xmlresults.length] = {code:"<xsl:value-of select='CASE_CODE'/>",
										desc:"<xsl:value-of select='DESCRIPTION'/>",
										case_int:"<xsl:value-of select='CASE_INT_CODE'/>",
										date_o:"<xsl:value-of select='DATE_OPENED'/>",
										vp_mscode:"<xsl:value-of select='UDDATA/FIELD4'/>",
										vp_msname:"<xsl:value-of select='UDDATA/FIELD5'/>",
										trnf_transtype_code:"<xsl:value-of select='UDDATA/FIELD8'/>",
										trnf_transtype_name:"<xsl:value-of select='UDDATA/FIELD9'/>",
										trnf_name:"<xsl:value-of select='UDDATA/FIELD10'/>",
										trnf_code:""};
		//alert(xmlresults.length);
  		</xsl:for-each>
		addRows();
	</script>
	</tbody>
</table>
<br/>
<table width="600" border="0" cellpadding="0" cellspacing="0">
  <tbody id="mainbodyulr" name="mainbodyulr">
  <tr>
    <td width="284" height="19" valign="top">Case description </td>
    <td width="122" valign="top">Date opened </td>
    <td width="122" valign="top">Case code </td>
  </tr>
	</tbody>
</table>
<br/>
<table width="600" border="0" cellpadding="0" cellspacing="0">
  <tbody id="mainbodylessulr" name="mainbodylessulr">
  <tr>
    <td width="284" height="19" valign="top">Case description </td>
    <td width="122" valign="top">Date opened </td>
    <td width="122" valign="top">Case code </td>
  </tr>
	</tbody>
</table>

My createRow function

Code:
function createRow( tbody, colour, id, col1, col2, col3, rowclass ){
	alert(tbody+" "+id+" "+col1+" "+col2+" "+col3);
	var tablebody = document.getElementById( tbody );
	//eval("var mainbody = " + tbody );
	//var tablebody = document.getElementsByTagName( "tbody" );
	//var tablebody = document.body.all(tbody);
	if(!tablebody)
		alert("the tbody element hasnt been found");
	
	var row = document.createElement( "tr" );
	row.setAttribute( "id", id ); // int code
	row.setAttribute( "bgColor", colour );
	row.className = rowclass;
	var cell_a = document.createElement( "td" );
	cell_a.setAttribute( "height", "12" );
	//cell_a.setAttribute( "className","firstCol" );
	cell_a.className = "firstCol";
	//cell_a.setAttribute( "width","30%" );
	var cell_link = document.createElement( "a" );
	cell_link.setAttribute( "href","javascript:void(0)" );
	//cell_link.setAttribute( "onclick","document_onclick()" );
	cell_link.setAttribute( "id", id );
	//cell_link.addEventListener("click",eventLis,false);
	cell_link.onclick = new Function("openFC(this)");
	//cell_link.setAttribute( "className", "insertedRowTitle" ); // this must be set 

	var link_txt = document.createTextNode( col1 );
	cell_link.appendChild( link_txt );
	cell_a.appendChild( cell_link );
	row.appendChild( cell_a );
	row.appendChild( insertCellInRow( col2 ) );
	row.appendChild( insertCellInRow( col3 ) );
	
	tablebody.appendChild( row );
}

All this works perfectly in Mozilla. Has anyone seen this before or have i found a bug in IE?

Regards

Matt
"Success is 10% inspiration, 90% last minute changes
 

- Where are you calling createRows?

- What parameters are you passing?

- Can you show more complete code that we can test (or give a URL to it)?

- Are you using the name attributes on the tbodies? If not, why not remove them.

Dan

 
- Where are you calling createRows?

This is called from within addRows() which I should have added originally. These are all the functions used...

Code:
function addRows(){
	for(var i=0; i < xmlresults.length; i++){
		//alert( casestep[i].code + " " + casestep[i].summary + "  " + casestep[i].total );
		var rowcolour;
		if( i % 2 == 0 ){ 	rowcolour = "";		
		}
		else{ rowcolour = ""; //#eeeeee
		}
		switch( xmlresults[i].trnf_transtype_code ){
			case "PI":
				var t = "mainbodypi";
		  		createRow( t, rowcolour, xmlresults[i].case_int, xmlresults[i].desc, xmlresults[i].date_o, xmlresults[i].code,"firstRow" );
		  		break;
		  	case "ULR":
				var t = "mainbodyulr";
				createRow( t, rowcolour, xmlresults[i].case_int, xmlresults[i].desc, xmlresults[i].date_o, xmlresults[i].code, "firstRow" );
		  		break;
		  	case "ULR5000":
				var t = "mainbodylessulr";
				createRow( t, rowcolour, xmlresults[i].case_int, xmlresults[i].desc, xmlresults[i].date_o, xmlresults[i].code, "firstRow" );
		  		break;
			default:	
				alert("going wrong");
				break;
		}
	}
}
function createRow( tbody, colour, id, col1, col2, col3, rowclass ){
	alert(tbody+" "+id+" "+col1+" "+col2+" "+col3);
	var tablebody = document.getElementById( tbody );
	//eval("var mainbody = " + tbody );
	//var tablebody = document.getElementsByTagName( "tbody" );
	//var tablebody = document.body.all(tbody);
	if(!tablebody)
		alert("the tbody element hasnt been found");
		
	var row = document.createElement( "tr" );
	row.setAttribute( "id", id ); // int code
	row.setAttribute( "bgColor", colour );
	row.className = rowclass;
	var cell_a = document.createElement( "td" );
	cell_a.setAttribute( "height", "12" );
	cell_a.className = "firstCol";
	var cell_link = document.createElement( "a" );
	cell_link.setAttribute( "href","javascript:void(0)" );
	cell_link.setAttribute( "id", id );
	cell_link.onclick = new Function("openFC(this)");

	var link_txt = document.createTextNode( col1 );
	cell_link.appendChild( link_txt );
	cell_a.appendChild( cell_link );
	row.appendChild( cell_a );
	row.appendChild( insertCellInRow( col2 ) );
	row.appendChild( insertCellInRow( col3 ) );
	
	tablebody.appendChild( row );
}
function insertCellInRow( celltxt ){
	var cell_b = document.createElement("td");
	cell_b.setAttribute( "height", "12" );
	cell_b.className = "lastCol";
	var txt = document.createTextNode( celltxt );
	cell_b.appendChild( txt );
	return cell_b;
}

The entire XSL page
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] xmlns:fo="[URL unfurl="true"]http://www.w3.org/1999/XSL/Format">[/URL]
<xsl:template match="VFILE_DATA">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Accept or Decline</title>
<script type="text/javascript" src="/portal/scripts/dhtmltable.js"></script>
<script type="text/javascript">
var xmlresults = new Array();
</script>
</head>
<body>
<input type="button" value="Refresh">
<xsl:attribute name="onclick">getPending('<xsl:value-of select="SESSION_KEY"/>')</xsl:attribute></input>

<table width="600" border="0" cellpadding="0" cellspacing="0">
  <tbody id="mainbodypi" name="mainbodypi">
  <tr>
    <td width="284" height="19" valign="top">Case description </td>
    <td width="122" valign="top">Date opened </td>
    <td width="122" valign="top">Case code </td>
  </tr>
  	<script type="text/javascript">
  		<xsl:for-each select="CASE">
		
		xmlresults[xmlresults.length] = {code:"<xsl:value-of select='CASE_CODE'/>",
										desc:"<xsl:value-of select='DESCRIPTION'/>",
										case_int:"<xsl:value-of select='CASE_INT_CODE'/>",
										date_o:"<xsl:value-of select='DATE_OPENED'/>",
										vp_mscode:"<xsl:value-of select='UDDATA/FIELD4'/>",
										vp_msname:"<xsl:value-of select='UDDATA/FIELD5'/>",
										trnf_transtype_code:"<xsl:value-of select='UDDATA/FIELD8'/>",
										trnf_transtype_name:"<xsl:value-of select='UDDATA/FIELD9'/>",
										trnf_name:"<xsl:value-of select='UDDATA/FIELD10'/>",
										trnf_code:""};

  		</xsl:for-each>
		addRows();
	</script>
	</tbody>
</table>
<br/>
<table width="600" border="0" cellpadding="0" cellspacing="0">
  <tbody id="mainbodyulr" name="mainbodyulr">
  <tr>
    <td width="284" height="19" valign="top">Case description </td>
    <td width="122" valign="top">Date opened </td>
    <td width="122" valign="top">Case code </td>
  </tr>
	</tbody>
</table>
<br/>
<table width="600" border="0" cellpadding="0" cellspacing="0">
  <tbody id="mainbodylessulr" name="mainbodylessulr">
  <tr>
    <td width="284" height="19" valign="top">Case description </td>
    <td width="122" valign="top">Date opened </td>
    <td width="122" valign="top">Case code </td>
  </tr>
	</tbody>
</table>

</body>
</html>
</xsl:template>
</xsl:stylesheet>

- What parameters are you passing?
You should now be able to see the call to createRow in the addRows function.

This is all still in testing internally so I cant direct you to the site yet.

- Are you using the name attributes on the tbodies? If not, why not remove them.
I put the name tags on the tbodies so I could test using getElementsByName. They dont dont seem to make a difference.



Matt
"Success is 10% inspiration, 90% last minute changes
 
getElementsByTagName() returns an array of matching objects. Your assignation for this wouldn't be useful.
 
getElementsByName in IE only works for <a> and form elements; this is a known bug.
 
My only other thought so far is that you're creating duplicate id element names in your code for the row and its internal href - IE might be upset by this and refuse to do getElementById correctly thereafter. I am just guessing, however.
 
getElementsByTagName() and getElementsByName() were used as alternatives (that failed) to getElementById and in the code above they are not used (i had loops in there to get the correct elements). Thank you for the info on getElementsByName() however - i've tried adding a form around the tables but it hasnt made a difference.
The id is unique for each row on the table because the xmlresults.case_int is a unique value.

Thanks
Matt
 
Here is some example XML that can be used against the pages above.

Code:
<?xml version="1.0"?>
<?xml-stylesheet type='text/xsl' href='/portal/acceptdecline.xsl'?>
<VFILE_DATA>
	<CASE>
		<CASE_HOLDER/>
		<CASE_CODE>0000708</CASE_CODE>
		<DESCRIPTION>0000708</DESCRIPTION>
		<APP_TYPE_DESCRIPTION>Visual Panel Instruction</APP_TYPE_DESCRIPTION>
		<DATE_OPENED>
			<DAY>01</DAY>
			<MONTH>02</MONTH>
			<YEAR>2005</YEAR>
		</DATE_OPENED>
		<MILESTONE_STATUS>Allocation</MILESTONE_STATUS>
		<CASE_INT_CODE>708</CASE_INT_CODE>
		<UDDATA>
			<FIELD2>0000708</FIELD2>
			<FIELD3>0000708</FIELD3>
			<FIELD4>ALLOCATION</FIELD4>
			<FIELD5>Allocated - waiting for acceptance</FIELD5>
			<FIELD6>ALLOCATION</FIELD6>
			<FIELD7>New instruction</FIELD7>
			<FIELD8>PI</FIELD8>
			<FIELD9>Personal Injury</FIELD9>
			<FIELD10>0000708</FIELD10>
		</UDDATA>
	</CASE>
	<CASE>
		<CASE_HOLDER/>
		<CASE_CODE>0000712</CASE_CODE>
		<DESCRIPTION>0000712</DESCRIPTION>
		<APP_TYPE_DESCRIPTION>Visual Panel Instruction</APP_TYPE_DESCRIPTION>
		<DATE_OPENED>
			<DAY>01</DAY>
			<MONTH>02</MONTH>
			<YEAR>2005</YEAR>
		</DATE_OPENED>
		<MILESTONE_STATUS>Allocation</MILESTONE_STATUS>
		<CASE_INT_CODE>712</CASE_INT_CODE>
		<UDDATA>
			<FIELD2>0000712</FIELD2>
			<FIELD3>0000712</FIELD3>
			<FIELD4>ALLOCATION</FIELD4>
			<FIELD5>Allocated - waiting for acceptance</FIELD5>
			<FIELD6>ALLOCATION</FIELD6>
			<FIELD7>New instruction</FIELD7>
			<FIELD8>PI</FIELD8>
			<FIELD9>Personal Injury</FIELD9>
			<FIELD10>0000712</FIELD10>
		</UDDATA>
	</CASE>
	<CASE>
		<CASE_HOLDER/>
		<CASE_CODE>0000713</CASE_CODE>
		<DESCRIPTION>0000713</DESCRIPTION>
		<APP_TYPE_DESCRIPTION>Visual Panel Instruction</APP_TYPE_DESCRIPTION>
		<DATE_OPENED>
			<DAY>01</DAY>
			<MONTH>02</MONTH>
			<YEAR>2005</YEAR>
		</DATE_OPENED>
		<MILESTONE_STATUS>Allocation</MILESTONE_STATUS>
		<CASE_INT_CODE>713</CASE_INT_CODE>
		<UDDATA>
			<FIELD2>0000713</FIELD2>
			<FIELD3>0000713</FIELD3>
			<FIELD4>ALLOCATION</FIELD4>
			<FIELD5>Allocated - waiting for acceptance</FIELD5>
			<FIELD6>ALLOCATION</FIELD6>
			<FIELD7>New instruction</FIELD7>
			<FIELD8>PI</FIELD8>
			<FIELD9>Personal Injury</FIELD9>
			<FIELD10>0000713</FIELD10>
		</UDDATA>
	</CASE>
	<CASE>
		<CASE_HOLDER/>
		<CASE_CODE>0000714</CASE_CODE>
		<DESCRIPTION>0000714</DESCRIPTION>
		<APP_TYPE_DESCRIPTION>Visual Panel Instruction</APP_TYPE_DESCRIPTION>
		<DATE_OPENED>
			<DAY>01</DAY>
			<MONTH>02</MONTH>
			<YEAR>2005</YEAR>
		</DATE_OPENED>
		<MILESTONE_STATUS>Allocation</MILESTONE_STATUS>
		<CASE_INT_CODE>714</CASE_INT_CODE>
		<UDDATA>
			<FIELD2>0000714</FIELD2>
			<FIELD3>0000714</FIELD3>
			<FIELD4>ALLOCATION</FIELD4>
			<FIELD5>Allocated - waiting for acceptance</FIELD5>
			<FIELD6>ALLOCATION</FIELD6>
			<FIELD7>New instruction</FIELD7>
			<FIELD8>PI</FIELD8>
			<FIELD9>Personal Injury</FIELD9>
			<FIELD10>0000714</FIELD10>
		</UDDATA>
	</CASE>
	<CASE>
		<CASE_HOLDER/>
		<CASE_CODE>0000719</CASE_CODE>
		<DESCRIPTION>0000719</DESCRIPTION>
		<APP_TYPE_DESCRIPTION>Visual Panel Instruction</APP_TYPE_DESCRIPTION>
		<DATE_OPENED>
			<DAY>01</DAY>
			<MONTH>02</MONTH>
			<YEAR>2005</YEAR>
		</DATE_OPENED>
		<MILESTONE_STATUS>Allocation</MILESTONE_STATUS>
		<CASE_INT_CODE>719</CASE_INT_CODE>
		<UDDATA>
			<FIELD2>0000719</FIELD2>
			<FIELD3>0000719</FIELD3>
			<FIELD4>ALLOCATION</FIELD4>
			<FIELD5>Allocated - waiting for acceptance</FIELD5>
			<FIELD6>ALLOCATION</FIELD6>
			<FIELD7>New instruction</FIELD7>
			<FIELD8>ULR5000</FIELD8>
			<FIELD9>Uninsured Loss Recovery Under 5000</FIELD9>
			<FIELD10>0000719</FIELD10>
		</UDDATA>
	</CASE>
	<CASE>
		<CASE_HOLDER/>
		<CASE_CODE>0000726</CASE_CODE>
		<DESCRIPTION>0000726</DESCRIPTION>
		<APP_TYPE_DESCRIPTION>Visual Panel Instruction</APP_TYPE_DESCRIPTION>
		<DATE_OPENED>
			<DAY>01</DAY>
			<MONTH>02</MONTH>
			<YEAR>2005</YEAR>
		</DATE_OPENED>
		<MILESTONE_STATUS>Allocation</MILESTONE_STATUS>
		<CASE_INT_CODE>726</CASE_INT_CODE>
		<UDDATA>
			<FIELD2>0000726</FIELD2>
			<FIELD3>0000726</FIELD3>
			<FIELD4>ALLOCATION</FIELD4>
			<FIELD5>Allocated - waiting for acceptance</FIELD5>
			<FIELD6>ALLOCATION</FIELD6>
			<FIELD7>New instruction</FIELD7>
			<FIELD8>PI</FIELD8>
			<FIELD9>Personal Injury</FIELD9>
			<FIELD10>0000726</FIELD10>
		</UDDATA>
	</CASE>
	<CASE>
		<CASE_HOLDER/>
		<CASE_CODE>0000727</CASE_CODE>
		<DESCRIPTION>0000727</DESCRIPTION>
		<APP_TYPE_DESCRIPTION>Visual Panel Instruction</APP_TYPE_DESCRIPTION>
		<DATE_OPENED>
			<DAY>01</DAY>
			<MONTH>02</MONTH>
			<YEAR>2005</YEAR>
		</DATE_OPENED>
		<MILESTONE_STATUS>Allocation</MILESTONE_STATUS>
		<CASE_INT_CODE>727</CASE_INT_CODE>
		<UDDATA>
			<FIELD2>0000727</FIELD2>
			<FIELD3>0000727</FIELD3>
			<FIELD4>ALLOCATION</FIELD4>
			<FIELD5>Allocated - waiting for acceptance</FIELD5>
			<FIELD6>ALLOCATION</FIELD6>
			<FIELD7>New instruction</FIELD7>
			<FIELD8>PI</FIELD8>
			<FIELD9>Personal Injury</FIELD9>
			<FIELD10>0000727</FIELD10>
		</UDDATA>
	</CASE>
	<CASE>
		<CASE_HOLDER/>
		<CASE_CODE>0000616</CASE_CODE>
		<DESCRIPTION>Personal Injury :- 0000616</DESCRIPTION>
		<APP_TYPE_DESCRIPTION>Visual Panel Instruction</APP_TYPE_DESCRIPTION>
		<DATE_OPENED>
			<DAY>18</DAY>
			<MONTH>01</MONTH>
			<YEAR>2005</YEAR>
		</DATE_OPENED>
		<MILESTONE_STATUS>Allocation</MILESTONE_STATUS>
		<CASE_INT_CODE>616</CASE_INT_CODE>
		<UDDATA>
			<FIELD2>0000616</FIELD2>
			<FIELD3>Personal Injury :- 0000616</FIELD3>
			<FIELD4>ALLOCATION</FIELD4>
			<FIELD5>Allocated - waiting for acceptance</FIELD5>
			<FIELD6>ALLOCATION</FIELD6>
			<FIELD7>New instruction</FIELD7>
			<FIELD8>PI</FIELD8>
			<FIELD9>Personal Injury</FIELD9>
			<FIELD10>Personal Injury :- 0000616</FIELD10>
		</UDDATA>
	</CASE>
	<CASE>
		<CASE_HOLDER/>
		<CASE_CODE>0000624</CASE_CODE>
		<DESCRIPTION>Personal Injury :- 0000624</DESCRIPTION>
		<APP_TYPE_DESCRIPTION>Visual Panel Instruction</APP_TYPE_DESCRIPTION>
		<DATE_OPENED>
			<DAY>29</DAY>
			<MONTH>01</MONTH>
			<YEAR>2005</YEAR>
		</DATE_OPENED>
		<MILESTONE_STATUS>Allocation</MILESTONE_STATUS>
		<CASE_INT_CODE>624</CASE_INT_CODE>
		<UDDATA>
			<FIELD2>0000624</FIELD2>
			<FIELD3>Personal Injury :- 0000624</FIELD3>
			<FIELD4>ALLOCATION</FIELD4>
			<FIELD5>Allocated - waiting for acceptance</FIELD5>
			<FIELD6>ALLOCATION</FIELD6>
			<FIELD7>New instruction</FIELD7>
			<FIELD8>PI</FIELD8>
			<FIELD9>Personal Injury</FIELD9>
			<FIELD10>Personal Injury :- 0000624</FIELD10>
		</UDDATA>
	</CASE>
	<CASE>
		<CASE_HOLDER/>
		<CASE_CODE>0000707</CASE_CODE>
		<DESCRIPTION>Personal Injury :- 0000707</DESCRIPTION>
		<APP_TYPE_DESCRIPTION>Visual Panel Instruction</APP_TYPE_DESCRIPTION>
		<DATE_OPENED>
			<DAY>01</DAY>
			<MONTH>02</MONTH>
			<YEAR>2005</YEAR>
		</DATE_OPENED>
		<MILESTONE_STATUS>Allocation</MILESTONE_STATUS>
		<CASE_INT_CODE>707</CASE_INT_CODE>
		<UDDATA>
			<FIELD2>0000707</FIELD2>
			<FIELD3>Personal Injury :- 0000707</FIELD3>
			<FIELD4>ALLOCATION</FIELD4>
			<FIELD5>Allocated - waiting for acceptance</FIELD5>
			<FIELD6>ALLOCATION</FIELD6>
			<FIELD7>New instruction</FIELD7>
			<FIELD8>PI</FIELD8>
			<FIELD9>Personal Injury</FIELD9>
			<FIELD10>Personal Injury :- 0000707</FIELD10>
		</UDDATA>
	</CASE>
	<CASE>
		<CASE_HOLDER/>
		<CASE_CODE>0000718</CASE_CODE>
		<DESCRIPTION>Personal Injury :- 0000718</DESCRIPTION>
		<APP_TYPE_DESCRIPTION>Visual Panel Instruction</APP_TYPE_DESCRIPTION>
		<DATE_OPENED>
			<DAY>01</DAY>
			<MONTH>02</MONTH>
			<YEAR>2005</YEAR>
		</DATE_OPENED>
		<MILESTONE_STATUS>Allocation</MILESTONE_STATUS>
		<CASE_INT_CODE>718</CASE_INT_CODE>
		<UDDATA>
			<FIELD2>0000718</FIELD2>
			<FIELD3>Personal Injury :- 0000718</FIELD3>
			<FIELD4>ALLOCATION</FIELD4>
			<FIELD5>Allocated - waiting for acceptance</FIELD5>
			<FIELD6>ALLOCATION</FIELD6>
			<FIELD7>New instruction</FIELD7>
			<FIELD8>PI</FIELD8>
			<FIELD9>Personal Injury</FIELD9>
			<FIELD10>Personal Injury :- 0000718</FIELD10>
		</UDDATA>
	</CASE>
	<CASE>
		<CASE_HOLDER/>
		<CASE_CODE>0000704</CASE_CODE>
		<DESCRIPTION>Uninsured Loss Recovery Under 5000 :- 0000704</DESCRIPTION>
		<APP_TYPE_DESCRIPTION>Visual Panel Instruction</APP_TYPE_DESCRIPTION>
		<DATE_OPENED>
			<DAY>01</DAY>
			<MONTH>02</MONTH>
			<YEAR>2005</YEAR>
		</DATE_OPENED>
		<MILESTONE_STATUS>Allocation</MILESTONE_STATUS>
		<CASE_INT_CODE>704</CASE_INT_CODE>
		<UDDATA>
			<FIELD2>0000704</FIELD2>
			<FIELD3>Uninsured Loss Recovery Under 5000 :- 0000704</FIELD3>
			<FIELD4>ALLOCATION</FIELD4>
			<FIELD5>Allocated - waiting for acceptance</FIELD5>
			<FIELD6>ALLOCATION</FIELD6>
			<FIELD7>New instruction</FIELD7>
			<FIELD8>ULR5000</FIELD8>
			<FIELD9>Uninsured Loss Recovery Under 5000</FIELD9>
			<FIELD10>Uninsured Loss Recovery Under 5000 :- 0000704</FIELD10>
		</UDDATA>
	</CASE>
	<QUERY_SELECTION>
		<INDEX>!QUERYvpfd</INDEX>
		<INDEX_COUNT>9</INDEX_COUNT>
		<ETYPE/>
		<ROLE/>
		<INFO/>
		<MAX_RETURN>-1</MAX_RETURN>
		<TIMEOUT>0</TIMEOUT>
		<WARNING>no</WARNING>
		<NOCHANGE>no</NOCHANGE>
		<STATUS/>
		<ORDER/>
		<FIELD_WIDTH>6</FIELD_WIDTH>
		<ENTRIES>12</ENTRIES>
		<MESSAGE/>
		<TEMP_FIELDS>allocation</TEMP_FIELDS>
	</QUERY_SELECTION>
	<PARAMS>
		<USER_ID>MATT</USER_ID>
		<USER_ENTITY_INT_CODE>12</USER_ENTITY_INT_CODE>
	</PARAMS>
	<SESSION_KEY>94Bccqdlniiiqckndk</SESSION_KEY>
</VFILE_DATA>

Matt
"Success is 10% inspiration, 90% last minute changes
 
Thank you for the info on getElementsByName() however - i've tried adding a form around the tables but it hasnt made a difference.
Ah, no, you misunderstand me. Only the elements that are considered sub-elements of a form - the <input> elements and the like - are available to the byName() function with IE. As I said, it's a bug.

The id is unique for each row on the table because the xmlresults.case_int is a unique value.
No, you set this id twice in each call to the function - once on the <tr> and once on the <a>. The same id. This is the flaw I'm pointing out.
 
I've removed the addition of the row id (thanks for pointing it out) but its made no difference.

Matt
"Success is 10% inspiration, 90% last minute changes
 
I've spotted one other thing which seems possible as a flaw; try replacing the three statements of the form:
Code:
  var t = "mainbodypi";
  createRow( t, rowcolour, xmlresults[i].case_int, xmlresults[i].desc, xmlresults[i].date_o, xmlresults[i].code,"firstRow" );
with
Code:
  createRow( "mainbodypi", rowcolour, xmlresults[i].case_int, xmlresults[i].desc, xmlresults[i].date_o, xmlresults[i].code,"firstRow" );
The case statments aren't block-level constructs, and you're defining var t in three places which could be considered to be all within one block. IE's behaviour would then be understandable, if not correct - it still ought to honour the assignation, but if it just dies on reaching the statement which attempts to create the created, you would get the behaviour you're reporting.
 
By alerting the first parameter in the createRow function i can tell the correct table id is being passed in. Tried this though but still no luck.

Matt
"Success is 10% inspiration, 90% last minute changes
 

Is it possible for you to upload this anywhere? As someone who doesn't use XML much, I'm still trying to work out how to "link-in" the sample XML data you've given to try and help you out here.

Dan

 
Hi Dan,
Dont think I can, no. Lets see if I can help you to help me though.
The xml file has a link to the xsl page so as soon as you try to open the XML in IE it will look to that link and load the XSL. That XSL will then parse the xml and the addRows function will be called.

Code:
<?xml-stylesheet type='text/xsl' href='/portal/acceptdecline.xsl'?>

As long as you have a virtual dir of 'portal' containing a scripts dir with the dhtmltable.js file containing the addRows and createRow function then it should work.

Thanks

Matt
"Success is 10% inspiration, 90% last minute changes
 
Beg your pardon, you dont have to use a virtual dir - you need to make some changes though.

Change the XML link to the XML to
Code:
<?xml-stylesheet type='text/xsl' href='acceptdecline.xsl'?>

Then change the link to the js in the xsl file so its a physical path (I'm sure you know how but for completeness....)
Code:
<script type="text/javascript" src="file://C:\<your path>\scripts\dhtmltable.js"></script>

This works for me so i hope this gets it working for you.
Thanks
Matt
 

Got it.

Your script is running before the tables have been created. Move your inline script to after all 3 tables, and everything works as expected.

Alternatively, and better IMHO, use the onload event of the body to run the script.

Hope this helps,
Dan

 
I'm not worthy! I'm not worthy!

Thats great thanks, Dan. Strange and somewhat worrying that Mozilla (FF 1) runs this fine. Maybe its something to do with speed that FF parses the doc - its so quick at creating the HTML that by the time the script is run the tables are there? Dont know.
I agree with the use of the onload event. I shall use that approach in future.

Anyway, ta very much.
Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top