You are not logged in.

1

Tuesday, October 4th 2011, 11:52am

Write to document (solved)

I was looking for a possibility to write text from a panorama to a file on the user's computer and found Downloadify, which can do this via JavaScript. So I have this code to add to the panorama.html:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<head>
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript" src="js/downloadify.min.js"></script>
</head>

<body onload="load();">

<form>
			<p>
				<label for="filename">Filename</label><br />
				<input type="text" name="filename" value="testfile.txt" id="filename" />
			</p>
			<p>
				<label for="data">File Contents</label><br />
<textarea cols="60" rows="10" name="data" id="data">
Whatever you put in this text box will be downloaded and saved in the file. If you leave it blank, no file will be downloaded</textarea>
			</p>
			<p id="downloadify">
				You must have Flash 10 installed to download this file.
			</p>
		</form>

		<script type="text/javascript">
			function load(){
				Downloadify.create('downloadify',{
					filename: function(){
						return document.getElementById('filename').value;
					},
					data: function(){ 
						return document.getElementById('data').value;
					},
					onComplete: function(){ alert('Your File Has Been Saved!'); },
					onCancel: function(){ alert('You have cancelled the saving of this file.'); },
					onError: function(){ alert('You must put something in the File Contents or there will be nothing to save!'); },
					swf: 'media/downloadify.swf',
					downloadImage: 'images/download.png',
					width: 100,
					height: 30,
					transparent: true,
					append: false
				});
			}
		</script>

</body>



And this for the panorama.xml:

Source code

1
<plugin name="save" url="save.png" onclick="js( load(get(variable1), get(variable2)) );" />


As I don't need the <form> I deleted it, but now (I guess) I have to rewrite these lines in the <body>:

Source code

1
2
return document.getElementById('filename').value;
return document.getElementById('data').value;


...but I don't know how. Can you help me? I'm sure it's very simple, but I couldn't manage to get it work.
0100011101101100011001010110100101100011 0110100000100000011010110110110001100001 0111010001110011011000110110100001110100 0110010101110100001011000010000001001010 0111010101101110011001110110010100101110 0010000001000101011000110110100001110100 0010000001101010011001010111010001111010 0111010000101110

This post has been edited 1 times, last edit by "Dr. Schneckem" (Oct 4th 2011, 3:05pm)


Zephyr

Professional

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

2

Tuesday, October 4th 2011, 2:16pm

try:

Source code

1
2
3
4
5
function load(var1, var2){

etc

}


And:

Source code

1
return document.getElementById('filename').value;


would be:

Source code

1
return var1;

3

Tuesday, October 4th 2011, 3:04pm

Great, it's working. Thank you very much! *smile*
0100011101101100011001010110100101100011 0110100000100000011010110110110001100001 0111010001110011011000110110100001110100 0110010101110100001011000010000001001010 0111010101101110011001110110010100101110 0010000001000101011000110110100001110100 0010000001101010011001010111010001111010 0111010000101110