controll statement not working

They have: 15 posts

Joined: Jun 2001

What's going on? Here's the problem:

I'm using Javascript in my webpage. I'm using

and I want to delete the file a user may pick. To do so, I've used

<script Language=Javascript>
function deletefile(){
if(Form1.file.value= " "){
window.alert(Please select a file.");}
else{
var fso, f1;
fso = new ActiveXOnject("Scripting.FileSystemObject");
f1 = fso.GetFile(Form1.file.value);
f1.Delete(); }

the window.alert... works good- a little too good. It seems that even if I select a file I still get the message "Please select a file" instead of going on to the else part of the controll statement. Is the value screwey when it comes to file types, do I need to use file.text instead of file.value, or what?

P.S. I did a test of the input box alone to see if the value right:

I see hello in my working environment (MS Frontpage) but I don't see it when I'm viewing my work in a browser- as if the browser totally disregards my programmed value. However, when I want to see the pathname of the file I just entered into the text box at runtime, file.value is fine. HELP!

Sticking out tongue

detox's picture

They have: 571 posts

Joined: Feb 2001

you need to have the quotes together like this "" rather than having a space in them, like this " ". Secondly i think the file, should stay, don;t replace it with text. That should get rid of the alert prob..

They have: 15 posts

Joined: Jun 2001

The spaces being together, along with two equal signs instead of one worked out... Thanks Shocked)

I wasn't trying to replace anything with text though. I was trying to alert the user that he or she needs to pick a file to actually delete, instead of leaving it blank. I did this because I noticed that if I clicked the delete button without there being a value, a runtime error would occur.

Hey, listen, one last request (or two rolled into one...)
1. Do you know how I would open a file similar in the same fashion? I tried
f1.OpenTextFile(...)
and every other thing I could think of with the world Open in there, but it's not responding or recognizing the method.

2. Do you know of a website where I can get some File System Object reference? That would solve every last one of my problems!

Thank you so much- you've been a big help.

~DizzE

detox's picture

They have: 571 posts

Joined: Feb 2001

As far as I know, client-side JavaScript won't do file-system work, even reading directory contents. If that is what you are attempting. Dont know much re server side....

For a complete list of all the methods and properties of the FSO, check out the Microsoft MSDN reference .

also check this out at wdvl : web developers virtual library

hope this helps some. BTW, upload and download are best done to my knowledge with upload managers like ASPUPLOAD.....

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.