How to read a file into an html doc (client side)?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • beacon
    Contributor
    • Aug 2007
    • 579

    How to read a file into an html doc (client side)?

    Hi everybody,

    This may end up being more of a javascript question, but I'm going to start here since I'm fairly inexperienced creating web pages AND because I'm limited to only creating client-side web pages at work (no web server...no budget for web server).

    Here's the gist of it all: I've created a basic client-side website (if you want to call it a website) where I've created multiple HTML documents and linked them together. I've got a CSS file that provides pretty much all the formatting for every page.

    One of the pages I have is for FAQs. Over the past couple of years I've just added individual questions to the top part of the page and the answers to those questions at the bottom of the page...pretty typical FAQ layout. The questions are hyperlinks to the bookmarked answers, and the answers have a bookmark to "Return to top" so the user can browse through the questions again.

    We recently began a new process that will require a number of new FAQs to be written and put in the page. However, another department, with no programming skills, will be providing the FAQs. In an effort to remove myself entirely from the process, I was trying to find a way that I could have the other department enter their questions in one file (maybe as a numbered list) and their answers in another. Then, find a way to import the questions/answers into the page when the page is loaded. I would prefer not to use iFrames for this and would prefer to have the text appear, and allow the existing CSS formatting to apply to the text, the same as it currently does.

    Is this possible? Is this the right forum for my question?

    Thanks,
    beacon
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    You're right, neither HTML or CSS can do this.

    Comment

    • beacon
      Contributor
      • Aug 2007
      • 579

      #3
      So doc, do you have any alternatives I can try out, our should I pack my things and jump to another forum?

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        You answered your own question. Javascript might do this or any other programming language.

        As far as the cost of web servers go, most of them are free and run on any old hardware you have lying around, so having an internal web site should not be holding you back.

        Comment

        • Niheel
          Recognized Expert Moderator Top Contributor
          • Jul 2005
          • 2432

          #5
          Store the files in XML or JSON text and then use javascript in the browser to parse the files.


          Ths link will show you how JSON and XML files can be used to store data

          Then what you want to do is parse these files with javascript.

          json in javascript:


          Either way, you'll have to store those data files somewhere, like on a webserver unless you're packaging them to be used locally.
          niheel @ bytes

          Comment

          • beacon
            Contributor
            • Aug 2007
            • 579

            #6
            Hi Niheel,

            I'm confused by your response...not that it's not a good response, I'm just not as well-versed in all things inter-web.

            Are you saying that I could create a text file with all 'FAQ' questions, numbered one to 50, close/save it, then use JSON to reference the file and Javascript to parse the file and display it in my HTML doc? If that's what you're saying, I didn't see how to do that in the link you provided.

            If that's not what you're saying, and what you're telling me is that I will have to take each of those 50 'FAQ' questions and put them in a JSON array, that's not really what I'm looking for. Is there no way to setup just a plain text file or Word document and read in the contents to the HTML doc?

            I'm somewhat familiar with JSON, but the users won't be and I guarantee you they won't be willing to learn. The best I can hope for from them is a numbered text file or Word doc.

            I'm limited entirely to the client-side for programming and storing the documents. Plus, there's my selfish desire to create something that other users can update so I never have to think about it again. =)

            Sorry to be difficult and thanks for your help,
            beacon

            Comment

            • Niheel
              Recognized Expert Moderator Top Contributor
              • Jul 2005
              • 2432

              #7
              Basically, store your data in XML files or Text files. Then use javascript to parse the data and display it in the htmls files you want.

              Since you want it to be updated by folks using word docs etc, why not use something like .NET to take word documents and then turn them into XML files that you can parse and display as you wish.

              How are you distributing these help files? Is it on one machine and everyone uses that machine? Do you send out update packages? or Are you storing the files on the web so that anyone can access them(from your prior response i take this is a no)?
              niheel @ bytes

              Comment

              • beacon
                Contributor
                • Aug 2007
                • 579

                #8
                I'm going to try to answer your questions as best I can without completely revealing myself as someone who really has no idea what he's doing...doh!

                XML files
                Don't these require formatting to be applied? Or can the users just save a Word document (we use 2003) with a .xml extension? Will any formatting that's been applied in the Word doc carry over to the XML and ultimately change the web page?

                Text files
                Would you recommend any particular layout to make this work? Would a numbered list be okay so long as the numbering is consistent (i.e. "1" vs. "1." vs. "1)")?

                Parsing using Javascript
                This is where I show my true colors...parsin g would be where I would analyze a group of characters/delimiters to determine where to start/stop reading in the file, right? Do you know of any good sites where I can learn how to do this? Unfortunately, my Javascript ability consists of searching on the web, copying/pasting, and hoping it works.

                .NET
                I don't have .NET and can't get .NET. It's a shame too. Just to put things into perspective so you can see how much I'm having to make out of so little, everything that I've done so far with this "website" has been done in Notepad. Not Notepad++...jus t Notepad. And I put "website" in quotations because I don't really think of it as a website in the traditional sense. I have a folder on a public network drive that has a bunch of HTML docs in it...that's the extent of the website.

                Distribution
                Currently, the content for the FAQs are hard coded into the HTML with the formatting applied (there's an external CSS file in the parent folder with the main HTML page). Since I've historically been the only one adding or removing items from the "website, I've just added/removed blocks of HTML as needed. I wouldn't say that I send out update packages...I just write, re-write, or overwrite the HTML files, using Notepad, then save it. As I mentioned in the last section, the "website" is basically just a bunch of HTML docs on a public network drive. Everyone can access the folder on the network, so opening any of the HTML docs is essentially the same as opening a Word document or Excel spreadsheet on a network. I like to think of this as an Extra-Intranet site since there's no web server.

                Thanks for being patient with me.

                Comment

                Working...