File read and write contents to text field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amulyab
    New Member
    • Dec 2007
    • 14

    File read and write contents to text field

    I have one text area and one button called import source code.When click on that button the text area named source code should get filled with the contents of the selected file.I have used browse button to select the file.How can i proceed now.Please help me.I need one java script for this.
  • amulyab
    New Member
    • Dec 2007
    • 14

    #2
    File read and write

    I have one text area and one button called import source code.When click on that button the text area named source code should get filled with the contents of the selected file.I have used browse button to select the file.How can i proceed now.Please help me.I need one java script for this.

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5388

      #3
      hi ...

      what does the file contain? plain text?

      kind regards

      Comment

      • amulyab
        New Member
        • Dec 2007
        • 14

        #4
        Originally posted by gits
        hi ...

        what does the file contain? plain text?

        kind regards
        Yes the file contains plain text.

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5388

          #5
          in that case you could use a hidden iframe and set its location to the file-source ... so the text will be loaded into it. now you may use a function like the following to get the content of the txt-file:

          [CODE=javascript]
          function get_iframe_cont ent(frame_name) {
          // refer the frame by name and the frame's document
          var doc = window.frames[frame_name].document;
          return doc.firstChild. innerHTML;
          }
          [/CODE]
          and set that as the value of the textarea.

          kind regards

          Comment

          Working...