469,917 Members | 1,690 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

File read and write contents to text field

14
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.
Dec 11 '07 #1
4 1887
amulyab
14
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.
Dec 11 '07 #2
gits
5,390 Expert Mod 4TB
hi ...

what does the file contain? plain text?

kind regards
Dec 11 '07 #3
amulyab
14
hi ...

what does the file contain? plain text?

kind regards
Yes the file contains plain text.
Dec 12 '07 #4
gits
5,390 Expert Mod 4TB
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:

Expand|Select|Wrap|Line Numbers
  1. function get_iframe_content(frame_name) {
  2.     // refer the frame by name and the frame's document
  3.     var doc = window.frames[frame_name].document;
  4.     return doc.firstChild.innerHTML;
  5. }
  6.  
and set that as the value of the textarea.

kind regards
Dec 12 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by =?Utf-8?B?ZGF2aWQ=?= | last post: by
7 posts views Thread by ianenis.tiryaki | last post: by
2 posts views Thread by Cliff72 | last post: by
24 posts views Thread by Bill | last post: by
15 posts views Thread by pakerly | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.