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!

Clearing a File Box!

Status
Not open for further replies.

Forri

Programmer
Oct 29, 2003
479
MT
Hi

I would like to clear the contents of a file textbox? how can i do it? i'm using this :

Code:
document.getElementById('path').value = '';

but nothing happens!

I can read its contents but cannot set them!

Thanks
Ncik
 
you can't do this because it's a security hole because you might specify a file from the operating system then automatically submit the form and you could get any file you want from the client's computer.

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
ohh! So what do you think i can do?

Nik
 
You can have a reset button:

<input type='Reset' />

...but it will reset all your form elements. If the file text box is the only one, then there's no problem!

If there are other elements, you could put them in another form so they are unaffected by the 'Reset', but you will have to grab their values and stick them in hidden INPUTs in the first form before submitting (if you want to pass their values).

'hope that helps.

--Dave
 
thanks Dave seems to be logical enough!

Cheers!

Ncik
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top