...

View Full Version : Form question



kshin
03-23-2005, 01:44 PM
lo all,

i want to reset a single field in a form. a file field to be specific.
i cant seem to get it to work :(

document.formname.formfield.reset(); doesnt work
i've looked around and tried other options too, but none of 'em seem to work..

help me plz ?? :)

martin_narg
03-23-2005, 02:17 PM
apologies - didn't mean to respond to this posting

dlg0351
03-23-2005, 03:07 PM
Try this:



document.formname.formfield.value='';

kshin
03-23-2005, 03:23 PM
that doesn't work.

it only works on text fields.

dlg0351
03-23-2005, 03:40 PM
What are you trying to reset then?

kshin
03-23-2005, 03:43 PM
i'm trying to reset a file field in a form.
one with a browse button next to it.

dlg0351
03-23-2005, 03:44 PM
If it is a textbox then this code will work, do you have code that I can look at?

Willy Duitt
03-23-2005, 04:23 PM
Input type=file is read only and for security reasons you can not manipulate it... the only way to reset that field without resetting the entire form is to remove and replace it with another simularly named field...



<script type="text/javascript">
<!--//
function reset_(file){
// Written By: WillyDuitt@hotmail.com || 03-23-2005 \\;
var input = document.createElement('input');
input.type = file.type;
input.name = file.name;
file.parentNode.replaceChild(input,file);
}
//-->
</script>
</HEAD>

<BODY>
<form action="http://google.com" method="get">
<input type="file" name="file">
<input type="text" name="text">
<input type="button" value="Reset" onclick="reset_(this.form['file'])">
<input type="submit">
</form>


.....Willy

kshin
03-24-2005, 09:10 AM
sweet !

that one works !

thanks for the help guys. appreciate it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum