Accessing File input text.

M

Mike

Hello,
I am trying to access the text in the file input field.
This is not working:


The function:
function post_value(){
opener.document.TestForm.parentform.value =
document.childform.fileinput.value;
self.close();
}

This is the form:
<form action="" method="get" enctype="application/x-www-form-
urlencoded" name="childform">
<input name="fileinput" type="file" />
<input type="submit" name="UploadandClose" id="UploadandClose"
value="UploadandClose" onclick="post_value();" />
</form>

Thanks
Mike
 
T

Thomas 'PointedEars' Lahn

If you want to upload a file without refreshing the main window, it
needs to be done with a combination of javascript and an iFrame.

Neither is "javascript" a necessity in this case, nor is an `iframe'.
An existing `iframe' element can be hidden with CSS, and instead of
an `iframe' element a `frame' element or another window can be used.

Please don't top-post.
http://www.jibbering.com/faq/faq_notes/clj_posts.html#ps1Post


PointedEars
 
M

Mike

Neither is "javascript" a necessity in this case, nor is an `iframe'.
An existing `iframe' element can be hidden with CSS, and instead of
an `iframe' element a `frame' element or another window can be used.

Please don't top-post.http://www.jibbering.com/faq/faq_notes/clj_posts.html#ps1Post

PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
  -- Richard Cornford, cljs, <[email protected]>

I am not concerned with uploading the file.
After I click the browse button and the file name is in the text box,
I want to access the text to pass it to a parent document.
Thanks
Mike
 
S

SAM

Mike a écrit :
I am not concerned with uploading the file.
After I click the browse button and the file name is in the text box,
I want to access the text to pass it to a parent document.

On the web you can't do that, it is formally forbidden !

You can only (try) to do it in local.


(*) try : the file given in the attached text-field will not be reached
so easily : there are so many ways to type a file's address ...
(depends of browser, depends of system)
 
T

Thomas 'PointedEars' Lahn

Mike said:
If you want to upload a file without refreshing the main window, it
needs to be done with a combination of javascript and an iFrame.
Neither is "javascript" a necessity in this case, nor is an `iframe'.
An existing `iframe' element can be hidden with CSS, and instead of
an `iframe' element a `frame' element or another window can be used.

Please don't top-post.
http://www.jibbering.com/faq/faq_notes/clj_posts.html#ps1Post
[...]

Please adhere to the aforementioned advisory and don't full-quote either.
I am not concerned with uploading the file.
After I click the browse button and the file name is in the text box,
I want to access the text to pass it to a parent document.

<form action="" onsubmit="post_value(this); return false">
<script type="text/javascript">
function post_value(o)
{
// see FAQ 4.10
var w;
if ((w = window.opener) && !w.closed)
{
w.document.forms["TestForm"].elements["parentform"].value =
o.elements["fileinput"].value;
}

window.close();
}
</script>

<input type="file" name="fileinput">
<input type="submit" value="Upload">
</form>

If eventually no upload would be involved, I wonder what you would do with
the local file path, though.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top