[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

search a .txt file and return results in HTML

If i have 2 text boxes and a button and a text file... How do I use the text entered in the first text box to search the .txt file and return the results into the second text box?  

Can I do this WITHOUT asp ?

thanks!
tanyag
0
TanyaG
Asked:
TanyaG
  • 4
  • 2
  • 2
  • +3
1 Solution
 
COBOLdinosaurCommented:
Can you do it without asp sure, but yu are going to have to have some kind of scripting language on the server.  An HTML page cannot access files.  You have to have some kind of search script.

Cd&
0
 
vdhantCommented:
Do you want to find the file on the server or on the client???
ant
0
 
CodingExpertsCommented:
If the file is not very big in size you can get if from the server when the page is being loaded, then you can make a javascript function that can search for the Text in the file without making a server call.

CodingExperts
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
TanyaGAuthor Commented:
Thanks!

What I would like to do is some sort of javascript function for the search button, like OnClick .. but can anyone supply some sort of code.. And can I use SQL in there or something? Like.. OnClick take the text from textbox1 and search .txt file for works LIKE the textbox1 and display in textbox2 (the entire string..)


TanyaG
0
 
TanyaGAuthor Commented:
BTW, this is just 1 text file and 1 html file. The text file contains a bunch of different books...
0
 
TanyaGAuthor Commented:
Is this valid?

SELECT ALL from books.txt ?
0
 
arataniCommented:
1. You need to use a database to do the SELECT ALL query. query.txt is just a text file.

2. I don't know if you can connect from a client (like javascript), all the way to your server which has the text file. It would be much easier if you can set up something like php or asp to read the text file and return the results.

Abhishek (AJ) Ratani
0
 
TanyaGAuthor Commented:
Do you know of any BASIC asp tutorials or examples I can look at?  I really don't know how to program in asp..
0
 
arataniCommented:
PHP is the easiest to install and use and its free and there are so many tutorials available,

http://www.php.net

AJ
0
 
vdhantCommented:
i ask my question again Do you want to find the file on the server or on the client???

Also how is IIS hard to install you put your window cd into the computer, you dont even need to use the internet.
ant
0
 
pmsyyzCommented:
Yes, use JavaScript to load a text file from the same server as the HTML file is on.

var req;

function loadXMLDoc(url) {
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();

        }
    }
}

// handle onreadystatechange event of req object
function processReqChange() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            processtext();
         } else {
            alert("There was a problem retrieving the XML data:\n" +
                req.statusText);
         }
    }
}


function processtext()
{
   .... do whatever...
}

document.onload = loadXMLDoc("DVDs.txt");


XMLHttpRequest is cool.  It is what Google uses to make Gmail so quick and responsive.

See http://developer.apple.com/internet/webcontent/xmlhttpreq.html
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now