Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reset the value of the file input path

 
Calvin Kong
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have a question about setting the value (to empty string, or anything) of the file input path. I was thinking it worked as the same way as a text field, but it's not. The value is not changed. So is there any trick to do that with the <input type="file" >?

Thanks a lot!

Calvin
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This might do it....

document.formName.elementName.reset();
 
Calvin Kong
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This works, but is there any way other than that? Since reset() will clear everything in the form. Is there any way that I can reset only the file upload field?

Thanks a lot.

Calvin
 
Yuriy Fuksenko
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create your own function that will go through the code, remember what was selected in each element, than do "reset" on form, and restore values.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic