944,084 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Dec 2nd, 2004
0

Capturing data from txt file using JavaScript/HTML

Expand Post »
I have successfully converted my .tiff file to a text file. This was a major step. My issue now that i am facing is "capturing" pertinent data. I am attempting to do this by running a JavaScript to create an HTML file from the .txt file. I am having trouble figuring out how I am going to pass the argument of a .txt file and embedding it into the HTML page.

Thoughts? Anyone? Bueller? Bueller?

dano
Reputation Points: 10
Solved Threads: 0
Newbie Poster
javadano is offline Offline
1 posts
since Dec 2004
Dec 10th, 2004
0

Re: Capturing data from txt file using JavaScript/HTML

JavaScript cannot read a text file. You need to use server side code, such as ASP.NET or PHP, to process a file and render it to HTML.

However, you can store large text strings as JavaScript variables, and use the JavaScript document.write() method to write HTML strings.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Dec 14th, 2004
0

Re: Capturing data from txt file using JavaScript/HTML

Not sure if this will help but a friend wrote some kind of script (.js, .class) or something of that nature to do just what you are wanting. I'll try to send him here to help you out! It was called awrite.js or jwrite.js. I know he had posted it on some java search site, just not sure which one. Once again i'll try to send him here to help you out! In the mean time try a search engine and put in awrite or jwrite. You might be able to find it on the net!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
LowelG is offline Offline
5 posts
since Dec 2004
May 25th, 2009
0

Re: Capturing data from txt file using JavaScript/HTML

I thought, Javascript can not work with FSO. It's good to see this article.

Ryan
<URL SNIPPED>
Last edited by peter_budo; May 25th, 2009 at 4:29 am. Reason: Keep It on The Site - Do not manually post "fake" signatures in your posts. Instead, you may create a sitewide signature within the user control panel.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ryansmith is offline Offline
5 posts
since Apr 2009
May 25th, 2009
0

Re: Capturing data from txt file using JavaScript/HTML

The only way to capture or embed .txt file into (x)HTML document, is to use AJAX. Just let me know if you need some example over this thing.
Featured Poster
Reputation Points: 114
Solved Threads: 138
Posting Shark
essential is offline Offline
973 posts
since Aug 2008
May 25th, 2009
0

Re: Capturing data from txt file using JavaScript/HTML

What about JQuery?? jQuery Documentation: http://docs.jquery.com/Ajax/load#urldatacallback
If not maybe try this code:
PHP Syntax (Toggle Plain Text)
  1. /*For safety reasons I would only allow the PHP file to determine the location of the file...if you want the ability to pick your file just post and I will modify my code*/
  2. $file = "test.txt"
  3. //Test if file exists
  4. if(file_exists($file))
  5. {
  6. //Open the file in read mode
  7. $fp = fopen($file, "r") or die("Error: Cannot open file");
  8. //Cycle through file
  9. while(!feof($fp))
  10. {
  11. //Return the file for AJAX to use
  12. echo fgets($fp);
  13. }
  14. }
  15. else { die("Error: Cannot find file"); }
Reputation Points: 47
Solved Threads: 47
Posting Whiz
FlashCreations is offline Offline
393 posts
since Sep 2008
May 25th, 2009
0

Re: Capturing data from txt file using JavaScript/HTML

Don't bust yourself guys. Original post was Dec 2004!!!

Airshow
Last edited by Airshow; May 25th, 2009 at 11:27 am.
Sponsor
Reputation Points: 318
Solved Threads: 358
WiFi Lounge Lizard
Airshow is offline Offline
2,527 posts
since Apr 2009
May 25th, 2009
0

Re: Capturing data from txt file using JavaScript/HTML

Oh wow I didn't realize that this thread was that old. Now that I think about it....was jQuery even around back then?
Reputation Points: 47
Solved Threads: 47
Posting Whiz
FlashCreations is offline Offline
393 posts
since Sep 2008
May 25th, 2009
0

Re: Capturing data from txt file using JavaScript/HTML

Oh wow I didn't realize that this thread was that old. Now that I think about it....was jQuery even around back then?
Good point FlashC. I think not http://docs.jquery.com/History_of_jQuery .

Airshow
Last edited by Airshow; May 25th, 2009 at 12:19 pm.
Sponsor
Reputation Points: 318
Solved Threads: 358
WiFi Lounge Lizard
Airshow is offline Offline
2,527 posts
since Apr 2009
May 25th, 2009
0

Re: Capturing data from txt file using JavaScript/HTML

Hi flash,

JQuery is made for shorthand ellaboration of Javascript lines and simplifies the way you write your programs.
And about that documentation that you've provided still uses AJAX Technology. If you will just take a good look over its frameworks, you'll see that all parts of it, is created by the method's, and properties of the Javascript language.

And also if he wants this with PHP, then im sure this query wouldn't be here in the first place.
Featured Poster
Reputation Points: 114
Solved Threads: 138
Posting Shark
essential is offline Offline
973 posts
since Aug 2008
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: javascript function onClick issue
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Making http post request on clicking a button





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC