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.
File read and write contents to text field
Collapse
X
-
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. -
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 regardsComment
Comment