0

Hi. I don't know where the problem is. The next codes is working on Google Chome but not in IE. I haven't tested yet on Firefox.

function.js

function getSheetCount() {
	var xmlhttp;
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	}
	else {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
			
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200) {
			var txt = xmlhttp.responseText;
			for(i=0; i<parseInt(txt); i++){
				document.getElementById('sheetNo').innerHTML+="<option value=\""+ i +"\">"+(i+1)+"</option>";
			}
		}
	}
	xmlhttp.open("GET","excelreader.php",true);
	xmlhttp.send();
}

excelreader.php

<?php
	error_reporting(E_ALL);
	require_once 'Classes/PHPExcel.php';
	$inputFileName = 'rf1.xls';
	$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
	echo $objPHPExcel->getSheetCount();
?>

index

<label>Sheet no:</label><select name="sheetNo" id="sheetNo"></select>

I tried prompting a dialog box on getSheetCount and it shows this error

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)
Timestamp: Mon, 23 May 2011 09:52:49 UTC


Message: 'document.getElementById(...)' is null or not an object
Line: 152
Char: 5
Code: 0
URI: http://localhost/final/javascript/functions.js

By the way, I am using Internet Explorer 8.


Please help me,
Michael

2
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by michaelzip
0

Hi twiss,

Thanks for the reply. It does not work either. What I did was I called the function on body tag, like this.

<body onload="startup()">
function startup(){
	//load startup functions
	getSheetCount();
}

When I tried to prompt the values I need, it executes it correctly. I also tried prompting a dialog box inside the loop on getSheetCount function and it shows the value correctly. I think the problem was on this code.

document.getElementById('sheetNo').innerHTML+="<option value=\""+ i +"\">"+(i+1)+"</option>"

I tried entering this code before the loop, and it does not show anything. Even inside the function startup();

document.getElementById('sheetNo').innerHTML = "<option value='Sample'>Sample</option>";
0

I found what was the problem.
I tried changing

document.getElementById('sheetNo').innerHTML+="<option value=\""+ i +"\">"+(i+1)+"</option>"

to

var opt = document.createElement('option');
opt.value = i;
opt.innerHTML = parseInt(i + 1);
document.getElementById('sheetNo').appendChild(opt);

and it works.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.