473,498 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reset a File Input

Hi,

Is this possible, if so how would you go about it.

I have a reasonably large form that includes 6 file input fields.
I wanted to create an option to allow the user to reset only the file input
fields. Currently if they select an image to upload and realise it is the
wrong one there is no way of resetting it. Except of course, manually
deleting the text out of the field.

Because you cannot reference and change the value of a file input, I cannot
set the value to "".

Is there any other way to add a rest button but specify the fields that you
want to reset. I do not want to rest the entire form.

Many thanks.

YoBro
Jul 23 '05 #1
9 8385
"YoBro" <yo***@wazzup.co.nz> skrev i meddelandet
news:nI*********************@news.xtra.co.nz...
Hi,

Is this possible, if so how would you go about it.

I have a reasonably large form that includes 6 file input fields.
I wanted to create an option to allow the user to reset only the file input fields. Currently if they select an image to upload and realise it is the
wrong one there is no way of resetting it. Except of course, manually
deleting the text out of the field.

Because you cannot reference and change the value of a file input, I cannot set the value to "".

Is there any other way to add a rest button but specify the fields that you want to reset. I do not want to rest the entire form.

Many thanks.

YoBro


I hope someone has a brighter idea than this: Save all form element values
except the file inputs, reset the form, then set all form element values
except the file inputs back to the corresponding saved values.

Joakim Braun
Jul 23 '05 #2
"YoBro" <yo***@wazzup.co.nz> wrote in message
news:nI*********************@news.xtra.co.nz
Hi,

Is this possible, if so how would you go about it.

I have a reasonably large form that includes 6 file input fields.
I wanted to create an option to allow the user to reset only the file
input fields. Currently if they select an image to upload and realise
it is the wrong one there is no way of resetting it. Except of
course, manually deleting the text out of the field.

Because you cannot reference and change the value of a file input, I
cannot set the value to "".

Is there any other way to add a rest button but specify the fields
that you want to reset. I do not want to rest the entire form.


Use two forms?
Jul 23 '05 #3
On 2004/09/07 22:57, in article ch**********@news6.svr.pol.co.uk, "PDannyD"
<da*****@REMOVETHISBITscenicplace.freeserve.co.u k> wrote:
"YoBro" <yo***@wazzup.co.nz> wrote in message
news:nI*********************@news.xtra.co.nz
Hi,

Is this possible, if so how would you go about it.

I have a reasonably large form that includes 6 file input fields.
I wanted to create an option to allow the user to reset only the file
input fields. Currently if they select an image to upload and realise
it is the wrong one there is no way of resetting it. Except of
course, manually deleting the text out of the field.

Because you cannot reference and change the value of a file input, I
cannot set the value to "".

Is there any other way to add a rest button but specify the fields
that you want to reset. I do not want to rest the entire form.


Use two forms?

I didn't know you couldn't mess with the value of a file input field. Never
had to try! But it makes sense that that is so from a security point of
view. Ah well, live and learn, eh.

I think what I'd do, is save the field values I wanted to keep into cookies
or global variables, reset the form and then restore the retained values to
their original fields from their temporary containers.

Maybe there's a more elegant way.

Cheers

Ian

Jul 23 '05 #4
Hmmm,

It is a really complicated form already, and massive, but quite a bit of
DHTML for different aspects of it. It is used specifically in Internet
Explorer, and is part of a companies Intranet. So I don't need anything
cross browser compatible, but I was hoping for an easy fix.

I thought about the cookie, idea but it is alot of work. I might have to
head down that road. It is a shame the reset button cannot have specified
values. This way you could click reset and specify which fields you want to
reset.

Thanks for the feedback!

"Ian Sedwell" <ia*********@btclick.com> wrote in message
news:BD63F4C5.CF1B%ia*********@btclick.com...
On 2004/09/07 22:57, in article ch**********@news6.svr.pol.co.uk,
"PDannyD"
<da*****@REMOVETHISBITscenicplace.freeserve.co.u k> wrote:
"YoBro" <yo***@wazzup.co.nz> wrote in message
news:nI*********************@news.xtra.co.nz
Hi,

Is this possible, if so how would you go about it.

I have a reasonably large form that includes 6 file input fields.
I wanted to create an option to allow the user to reset only the file
input fields. Currently if they select an image to upload and realise
it is the wrong one there is no way of resetting it. Except of
course, manually deleting the text out of the field.

Because you cannot reference and change the value of a file input, I
cannot set the value to "".

Is there any other way to add a rest button but specify the fields
that you want to reset. I do not want to rest the entire form.


Use two forms?

I didn't know you couldn't mess with the value of a file input field.
Never
had to try! But it makes sense that that is so from a security point of
view. Ah well, live and learn, eh.

I think what I'd do, is save the field values I wanted to keep into
cookies
or global variables, reset the form and then restore the retained values
to
their original fields from their temporary containers.

Maybe there's a more elegant way.

Cheers

Ian

Jul 23 '05 #5

"YoBro" <yo***@wazzup.co.nz> wrote in message
news:nI*********************@news.xtra.co.nz...
Hi,

Is this possible, if so how would you go about it.

I have a reasonably large form that includes 6 file input fields.
I wanted to create an option to allow the user to reset only the file input fields. Currently if they select an image to upload and realise it is the
wrong one there is no way of resetting it. Except of course, manually
deleting the text out of the field.

Because you cannot reference and change the value of a file input, I cannot set the value to "".
document.forms['yourFormName'].yourFileInputName.value=""; Is there any other way to add a rest button but specify the fields that you want to reset. I do not want to rest the entire form.
<form name='yourFormName' onsubmit='yourFunction()>
<input type="file" name="yourFileInputName">
</form>
<script type=text/javascript>
function yourFunction() {
// validate what you want here;
// change form field value as necessary (see above comment)
if(!confirm("Ok to submit or whatever") return;
}
</script>
Jimbo Many thanks.

YoBro

Jul 23 '05 #6

YoBro a écrit:
Hi,

Is this possible, if so how would you go about it.

I have a reasonably large form that includes 6 file input fields.
I wanted to create an option to allow the user to reset only the file input
fields. Currently if they select an image to upload and realise it is the
wrong one there is no way of resetting it. Except of course, manually
deleting the text out of the field.
essayez avec 6 forms plus une qui récapitule
et soumettez par la methode submit après avoir collationné les fichiers
valides

test with 6 forms more one which recapitulates and submit by the method
..submit() after having collated the valid files

GR

Because you cannot reference and change the value of a file input, I cannot
set the value to "".

Is there any other way to add a rest button but specify the fields that you
want to reset. I do not want to rest the entire form.

Many thanks.

YoBro


Jul 23 '05 #7
On 8/9/04 1:58 am, YoBro wrote:
Hmmm,

It is a really complicated form already, and massive, but quite a bit of
DHTML for different aspects of it. It is used specifically in Internet
Explorer, and is part of a companies Intranet. So I don't need anything
cross browser compatible, but I was hoping for an easy fix.


Associate each file input field with a checkbox that toggles the field's
'disabled' flag. (Disabled fields are always unsuccessful, so their contents
should be ignored.)

--
Philip Ronan
ph***********@virgin.net
(Please remove the "z"s if replying by email)
Jul 23 '05 #8
Hi,

You cannot change a file input field with JavaScript (for security reasons).
So this method won't work.

YoBro
"J. J. Cale" <ph****@netvision.net.il> wrote in message
news:41********@news.012.net.il...

"YoBro" <yo***@wazzup.co.nz> wrote in message
news:nI*********************@news.xtra.co.nz...
Hi,

Is this possible, if so how would you go about it.

I have a reasonably large form that includes 6 file input fields.
I wanted to create an option to allow the user to reset only the file

input
fields. Currently if they select an image to upload and realise it is the
wrong one there is no way of resetting it. Except of course, manually
deleting the text out of the field.

Because you cannot reference and change the value of a file input, I

cannot
set the value to "".

document.forms['yourFormName'].yourFileInputName.value="";
Is there any other way to add a rest button but specify the fields that

you
want to reset. I do not want to rest the entire form.

<form name='yourFormName' onsubmit='yourFunction()>
<input type="file" name="yourFileInputName">
</form>
<script type=text/javascript>
function yourFunction() {
// validate what you want here;
// change form field value as necessary (see above comment)
if(!confirm("Ok to submit or whatever") return;
}
</script>
Jimbo
Many thanks.

YoBro


Jul 23 '05 #9
Hi,

This was going to be my option, and have sort of implemented it, if they
re-use an image already on the server. It disables the file input so they
cannot upload an image as well as re-use an image.

YoBro

"Philip Ronan" <ph***********@virgin.net> wrote in message
news:BD649160.20CC8%ph***********@virgin.net...
On 8/9/04 1:58 am, YoBro wrote:
Hmmm,

It is a really complicated form already, and massive, but quite a bit of
DHTML for different aspects of it. It is used specifically in Internet
Explorer, and is part of a companies Intranet. So I don't need anything
cross browser compatible, but I was hoping for an easy fix.


Associate each file input field with a checkbox that toggles the field's
'disabled' flag. (Disabled fields are always unsuccessful, so their
contents
should be ignored.)

--
Philip Ronan
ph***********@virgin.net
(Please remove the "z"s if replying by email)

Jul 23 '05 #10

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

Similar topics

9
29973
by: Ken | last post by:
How can I reset the initial form variables that are set with session statements when clicking on a button? I tried this but the function was not called: <?PHP function reset_form($none) {...
2
2621
by: Charles M. Fish, Sr. | last post by:
I’m so tired from banging this problem around all day, I hope I can explain it succinctly & accurately. I want to execute a function immediately following a click on <input type="RESET"... ...
1
2449
by: Michael Hill | last post by:
This reset type in my input tag really is not resetting the values. <input type="reset" value=" Clear "> Follow me for a minute. I have 2 selects. When I have a select1 that has some kind...
2
8071
by: Matt | last post by:
i need to implement a clear button to clear all the fields in the form, but i am thinking i can just use reset button. <input type="reset" name="reset" value="CLEAR"> The first thought is...
1
14265
by: NancyASAP | last post by:
Thought I'd share this since it took me a long time to get it working. Thanks to a bunch of contributers in Google Groups who shared javascript, etc. The question was: How can I put a reset...
2
5216
by: Roger Withnell | last post by:
I need to reset a form to its original value using onclick rather than the Reset button. So, I have: <input type="button" name="reset" id="reset" value="Reset" onclick="form1.reset();"> where...
11
7391
by: newbie | last post by:
i have a form in which a hidden field (initial value as '0', and my javascript set it to '1' when an event is trigged). In the same form, i have a reset field. But I realized that the hidden field...
7
3464
by: hotflash | last post by:
Hi All, I want to creat a script where I will allow user to reset their own password. I have tried different options but don't have any luck. Wonder what I want to do is kinda not valid or not. ...
3
1702
by: artev | last post by:
if in a page I have a search form and I want use the method reset() for reinsert the default values, I notice that after a research, for the method reset(), the default values aren't more that...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
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...
1
6887
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...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4910
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...
0
3093
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...
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
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...

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.