View Full Version : Searching Text file with Javascript

07-15-2010, 09:07 PM
Im trying to use javascript to search a text file. text file is like this...

1111111[TAB]Project Name[TAB]Application1
2222222[TAB]Project Name[TAB]Application2

Im trying to get the javascript to let a user search for number or project name, if found it displays all the info if found. application1 or application2 (whatever is in the 3rd area)
The text file can also be seperated by commas, either way is fine.

can anyone help with this. ?

Old Pedant
07-15-2010, 09:34 PM
Where is the text file?? It must come from the same domain for this to be possible.

07-15-2010, 09:51 PM
yes . same domain in the same directory as the web page.

Also if nothing is found from the 2 search criteria, would be great for it to say a message "like nothing found. bla bla bla."

Old Pedant
07-15-2010, 09:54 PM
Do I need to show the code to open and grab file contents? Using XMLHTTP? Or do you know all that?

Back later. Meeting.

07-15-2010, 09:55 PM
can you please show it all ?

Old Pedant
07-15-2010, 11:25 PM

Do a VIEW==>>SOURCE (or PAGE SOURCE) to see the code.

The text file is http://www.mywhizbang.com/sampledata.txt

Contents are this:

123 WASH-1 Wash the windows
123 PLAY-1 Play with the dog
456 WASH-2 Wash the car
789 WASH-3 Wash the dog
456 PLAY-2 Play with the kids

07-16-2010, 02:52 PM
You are the friggin man. thank you.

another couple questio
I added a clear button which is clearing the text fields, but can i also make that same reset button clear the div tag text

Old Pedant
07-16-2010, 08:44 PM
<input type="reset" value="Reset" onclick="document.getElementById('RESULTS').innerHTML=' ';">

07-16-2010, 09:24 PM
thank you !!!!