Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ActiveX hlp with save as 1

Status
Not open for further replies.

codeone

Programmer
Mar 25, 2003
343
US
hey,
I have been trying to set a variable in this activex script i got a while back from lrnmore a resident here...

I can't seem to get it right...I am hoping someone could add to my code:

a prompt box that asks the user: Name of file and extention?

the user would then type: someThing.txt (could be any name or ext)

and the text in the textarea would be saved as someThing.txt.

here's my code:

Code:
<script>
function strtxt1(txt){
 var strObj = new ActiveXObject('Scripting.FileSystemObject');
 var strFile = strObj.OpenTextFile('MyText.txt', 2, true);
  if(!txt) {
   txt = opener.document.alpha.beta.value }
   strFile.WriteLine(txt);
   strFile.Close();
}
</script>

again,

I am trying for a prompt box that asks the user what to name the file that is getting ready to be saved, which is the text in the textarea...to do this I would like to set a variable and place it in place of the "MyText.txt" string...

that way whatever name/ext the user types in the prompt box will be the name/ext the file is saved as... instead of how it is now defaulting to my pre-defined name/ext "MyText.txt"

thanks

co

 
Codeone,

How you been?

See if this will help you get where you're going.

Code:
<html><head>
<script>
function strtxt1(txt){
var fileName = prompt('Please Enter a File Name..','Example: myfile.txt');
var strObj = new ActiveXObject('Scripting.FileSystemObject');
var strFile = strObj.OpenTextFile(fileName, 2, true);
if(!txt) {
txt = opener.document.alpha.beta.value;}
strFile.WriteLine(txt);
strFile.Close();
}
</script></head><body>
<a href="Save As" onClick="strtxt1();return false;">Test Save</a>
</body></html>

Great Javascript Resource:
 
Lrnmore,

Hey man, Im doing good...

yeah man, that's exactly what I was trying to do...thanks alot!!!

regards

codeone
 
hey lrnmore,

i forgot my manners... I know that you probably don't care much about the stars, but I still need to give you one, for all the help you've been giving me since I've started here, so here it is buddy...thanks again for all the awesome scripts and links you've given me, I seriously would not get anything (hard) done if you haven't helped me out ALL those times... you literally provided and countinue to provide the means to finish what I started...so again, thanks alot...

see ya around,

co
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top