Capturing data from txt file using JavaScript/HTML

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Dec 2004
Posts: 1
Reputation: javadano is an unknown quantity at this point 
Solved Threads: 0
javadano javadano is offline Offline
Newbie Poster

Capturing data from txt file using JavaScript/HTML

 
0
  #1
Dec 2nd, 2004
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Capturing data from txt file using JavaScript/HTML

 
0
  #2
Dec 10th, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 5
Reputation: LowelG is an unknown quantity at this point 
Solved Threads: 0
LowelG's Avatar
LowelG LowelG is offline Offline
Newbie Poster

Re: Capturing data from txt file using JavaScript/HTML

 
0
  #3
Dec 14th, 2004
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!
:eek: Looking 4 Java in all the wrong places!LowelGoss@msn.com
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 5
Reputation: ryansmith is an unknown quantity at this point 
Solved Threads: 0
ryansmith ryansmith is offline Offline
Newbie Poster

Re: Capturing data from txt file using JavaScript/HTML

 
0
  #4
May 25th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Capturing data from txt file using JavaScript/HTML

 
0
  #5
May 25th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 184
Reputation: FlashCreations is an unknown quantity at this point 
Solved Threads: 15
FlashCreations's Avatar
FlashCreations FlashCreations is offline Offline
Junior Poster

Re: Capturing data from txt file using JavaScript/HTML

 
0
  #6
May 25th, 2009
What about JQuery?? jQuery Documentation: http://docs.jquery.com/Ajax/load#urldatacallback
If not maybe try this code:
  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"); }
FlashCreations
(aka PhpMyCoder)

About Me | My Blog | Contact Me
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 836
Reputation: Airshow is on a distinguished road 
Solved Threads: 120
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark

Re: Capturing data from txt file using JavaScript/HTML

 
0
  #7
May 25th, 2009
Don't bust yourself guys. Original post was Dec 2004!!!

Airshow
Last edited by Airshow; May 25th, 2009 at 11:27 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 184
Reputation: FlashCreations is an unknown quantity at this point 
Solved Threads: 15
FlashCreations's Avatar
FlashCreations FlashCreations is offline Offline
Junior Poster

Re: Capturing data from txt file using JavaScript/HTML

 
0
  #8
May 25th, 2009
Oh wow I didn't realize that this thread was that old. Now that I think about it....was jQuery even around back then?
FlashCreations
(aka PhpMyCoder)

About Me | My Blog | Contact Me
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 836
Reputation: Airshow is on a distinguished road 
Solved Threads: 120
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark

Re: Capturing data from txt file using JavaScript/HTML

 
0
  #9
May 25th, 2009
Originally Posted by FlashCreations View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Capturing data from txt file using JavaScript/HTML

 
0
  #10
May 25th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC