Re: can't read value from <input type=file> in netscape



myahact@xxxxxxxx said the following on 10/29/2005 3:54 PM:
Hello,

I have <input type=file id=myfile> in a form.
In IE I can read the value thusly:

document.getElementById("myfile").value

But thusly returns "" in Mozilla/Netscape.

I also tried through the DOM but

node.value was ""
node.text was ""

Can I not read this value in Moz/NS?

Yes, you use a name attribute and the forms collection:

<script type="text/javascript">
function getValue(formRef){
alert(formRef.fileInput.value)
}
</script>

<form name="myForm">
<input type="file" onchange="alert(this.value)" name="fileInput"><br />
<input type="button" value="Get The Value"
       onclick="getValue(this.form)">

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
.


Quantcast