Click to See Complete Forum and Search --> : How do I make a save button work?


zapdos900
03-11-2003, 08:43 PM
How do I make a save button work?

pyro
03-11-2003, 09:08 PM
Don't post the same questions twice.

<html>
<head>
<title>Save</title>
<script language="javascript" type="text/javascript">

function save()
{
val = document.myform.text_area.value;
mydoc = document.open();
mydoc.write(val);
mydoc.execCommand("saveAs",true,".txt"); //you can change the .txt to your extention
history.go(-1);
}

</script>
</head>
</body>
<form name="myform">
<input type="button" onClick="save();" value="Save">
<br>
<textarea name="text_area" id="text_area_id" rows="14" cols="40"></textarea>
</form>
</body>
</html>

That will work in IE 5.5+

pyro
03-11-2003, 09:13 PM
I just saw that you posted in four other forums (CGI, HTML, General, and Feedback), not including you double post in these forums. That is totally inappropriate. I suggest you go and delete those extra posts. Don't make people regret helping you. :mad: I am tempted to delete the answer that I gave you...

zapdos900
03-11-2003, 09:31 PM
sorry!

Your code has a problem.

http://members.cox.net/ericchristian/images/help.jpg

pyro
03-11-2003, 09:43 PM
What browser and version are you using?

zapdos900
03-12-2003, 05:04 PM
Its working now but it wont change the extention.:o

pyro
03-12-2003, 05:06 PM
It works fine for me. You can only save as either .txt or .html, but you are able to save as both.

to change the default, change mydoc.execCommand("saveAs",true,".txt"); to mydoc.execCommand("saveAs",true,".html");

zapdos900
03-12-2003, 05:11 PM
No,

I want a diffrent extention!

pyro
03-12-2003, 05:21 PM
change mydoc.execCommand("saveAs",true,".txt"); to mydoc.execCommand("saveAs",true,".ext");

I just tested with .php and it worked...

zapdos900
03-12-2003, 05:43 PM
not me.

pyro
03-12-2003, 06:04 PM
Talk in more than monosylables, ok? I'm giving you free advise here, and would hope that you appreciate it more than you are showing. What does your document.execCommand look like?

2ji8888
05-18-2010, 11:57 PM
how can we keep on saving using the same file without ovewritting already saved info, using this script?? is it possible?