0

OK folks - all suggestions gratefully accepted. I am a relative novice hitting head against hard brick wall.

Basically what I am doing is reading a user parameter file to produce multiple reports. I have this working perfectly in Firefox using the AddEventListener and FileReader functions. IE8 does not allow me to do this -I have tried AttachEvent (see MSIE and addEventListener Problem in Javascript?) which will list the files but does not allow me to read the user selected one. (Why Microsoft considers this a security exposure and Mozilla do not perplexes me.)

I do not want the user to have to input all the data into a form as I want the data to be re-usable i.e. I envisage users making small changes to a small selection of parameters every so often and re-running.

Apart from doing a check for IEx and telling them to use another browser, is there another method anyone would recommend?

Thanks in anticipation

Community
  • 1
  • 1
  • Could you lay out the specifics of what you've tried and an example of input/output you expect (or input/output behavior)? It would help make things more clear. (also, try using list formatting) – Jeff Tratner Jun 10 '12 at 06:43

2 Answers2

0

Hi basically I have a flat parameter file that I want to read from users computer (in specified format) that will then produce reports. Necessity being the mother of invention I have come up with an alternative solution to reading the file. That is to copy the file contents into a text area and then use to process it

<textarea id="myTextarea" cols="45" rows="20">Copy in here</textarea>

<br />
<button type="button" onclick="readParameters()">then click here</button>
<script>
function readParameters()
{contents=document.getElementById("myTextarea").value;}
</script>

Not as neat as selecting a file but at least it works with IE

0

User1446214 has got the right idea, I've added a compatibility check by using and if statement and put the text area in a JQuery dialog box if the file reader fails:

if (window.File && window.FileReader && window.FileList && window.Blob) {
// load file code
} else {
//open jquery dialog box with text area
$("#fileInputDialog").dialog("open");

}

stephenjgray
  • 15
  • 1
  • 6