473,563 Members | 2,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple problem: change file input field value?

Hi anyone know how to change or even just clear the value of a file
input field using javascript?

document.getEle mentById('field name').value='n ewvalue';

doesnt work as you would expect.

Cheers,
Ciarán

Mar 4 '07 #1
4 9885
Ciaran wrote:
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
Mar 4 '07 #2
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

Mar 4 '07 #3
ASM
Matt Kruse a écrit :
Ciaran wrote:
>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
Mar 4 '07 #4
"Ciaran" <cr*******@hotm ail.comwrote:
>
>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"...j ust as it clears anything else.

--
Tim Slattery
Sl********@bls. gov
http://members.cox.net/slatteryt
Mar 5 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
4738
by: Samantha Smit | last post by:
Hi, I am trying to create a simple asp page that has one command button that updates a database. The URL of the page is like this: http://MyServer.com/Update.asp?UserName=Tom My asp code is like this: %@ Language=VBScript %> <!--#include file="includes/openconnection.asp"-->
1
6409
by: Veverita | last post by:
Hi there I'm hoping that someone can help me with a question I have about javascript syntax. I got an html page that uploads an image and some text field to a database. What I'd like to do is modify the content of one of the textfields prior to it being submitted to the database. Specifically, I need to
5
3087
by: Digital Puer | last post by:
I have the following HTML form: - radio button A (default selected) - radio button B - input field, of type "file" with "Choose" button - submit button I would like to have it so that if the user clicks on the "Choose" button of the input field (to select a file on the local disk), then radio button B is automatically
0
1874
by: 42 | last post by:
I implemented a simple class inherited from Page to create a page template. It simply wraps some trivial html around the inherited page, and puts the inherited page into a form. The problem I have run into is that the emitted html at the end of the process is slightly different and doesn't work. Please don't be put off by all the source...
0
3202
by: Daniel Sélen Secches | last post by:
I found a good class to do a simple FTP. Very good.... I'm posting it with the message, i hope it helps someone ============================================================== Imports System.Net
27
4595
by: one man army | last post by:
Hi All- I am new to PHP. I found FAQTS and the php manual. I am trying this sequence, but getting 'no zip string found:'... PHP Version 4.4.0 $doc = new DomDocument; $res = $doc->loadHTMLFile("./aBasicSearchResult.html"); if ( $res == true ) { $zip = $doc->getElementById('zipRaw_id')->value; if ( 0 != $zip ) {
12
2375
by: rahul gupta | last post by:
hi this is rahul here i am stucked in 1 problem.......... i have 2 input box and in my xsl file .1st will display the card no. of student and the second will display the amount in his balance field.this data i am retreving from my xml file. now what i want is to edit the card no. and amount field but ,there is 1validation that if the ...
2
3139
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if i change something in php file using in ajax function.it not refreshed,means its shows the previous result it not get updated.i can't understand...
6
3513
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features to an old program that I wrote in delphi and it's a good opportunity to start with c++.
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.