Connecting Tech Pros Worldwide Forums | Help | Site Map

Simple problem: change file input field value?

Ciaran
Guest
 
Posts: n/a
#1: Mar 4 '07
Hi anyone know how to change or even just clear the value of a file
input field using javascript?

document.getElementById('fieldname').value='newval ue';

doesnt work as you would expect.

Cheers,
Ciarán


Matt Kruse
Guest
 
Posts: n/a
#2: Mar 4 '07

re: Simple problem: change file input field value?


Ciaran wrote:
Quote:
Hi anyone know how to change or even just clear the value of a file
input field using javascript?
Because of security restrictions in browsers, you can't change the value of
file input fields. Ever. Period.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com


Ciaran
Guest
 
Posts: n/a
#3: Mar 4 '07

re: Simple problem: change file input field value?


Quote:
Because of security restrictions in browsers, you can't change the value of
file input fields. Ever. Period.
Bugger! Is there any work around to cancel the sending of the file? I
basically want to provide a cancel button in case the user changes
their mind about a file.

Cheers,
Ciarán

ASM
Guest
 
Posts: n/a
#4: Mar 4 '07

re: Simple problem: change file input field value?


Matt Kruse a écrit :
Quote:
Ciaran wrote:
Quote:
>Hi anyone know how to change or even just clear the value of a file
>input field using javascript?
>
Because of security restrictions in browsers, you can't change the value of
file input fields. Ever. Period.
Anyway ... what that for ?

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Tim Slattery
Guest
 
Posts: n/a
#5: Mar 5 '07

re: Simple problem: change file input field value?


"Ciaran" <cronoklee@hotmail.comwrote:
Quote:
>
Quote:
>Because of security restrictions in browsers, you can't change the value of
>file input fields. Ever. Period.
>
>Bugger! Is there any work around to cancel the sending of the file? I
>basically want to provide a cancel button in case the user changes
>their mind about a file.
Well...you can have a "Cancel" button on the form, which would close
the window or route the user someplace else or whatever else you can
think of.

And I think that the normal "Reset" button (<input type="reset"...>)
will clear an <input type="file"...just as it clears anything else.

--
Tim Slattery
Slattery_T@bls.gov
http://members.cox.net/slatteryt
Closed Thread


Similar JavaScript / Ajax / DHTML bytes