469,290 Members | 1,887 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,290 developers. It's quick & easy.

File Open Dialog Box

Pai
Hello there,

I would like to open a "Chose File " dialog box using javascript.

I am using C# as the server side programming language.

I have tried <Input type="file" tag, and then "showModalDialog".

any help please.

Kind Regards,
Pai
Jul 20 '05 #1
6 25714
sp**@immunetolerance.org (Pai) writes:
I would like to open a "Chose File " dialog box using javascript. I am using C# as the server side programming language.
I have tried <Input type="file" tag, and then "showModalDialog".
That would be serverside, and will ofcourse not work on the client.
any help please.


If you have
<form id="foo">
<input type="file" name="bar">
</foo>
then in IE, you can activeate the file input by simulating
a click on the input: document.forms['foo'].elements['bar'].click()

It doesn't work in Mozilla or Opera.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
hello Irn,

Thanks for your reply, on the devdex.com forum.

Actually, when I click on tbe browse button <input type=file name=bar>.

I would like the selected file name to be inseted in a text field which
is placed next to the button.

I tried using a onclick event but it gets fired before the dialog box is
displayed so i cannot retrieve the name

<input type =text name=mytext>
<input type=file name=bar onclick='fn_test()'>.

function fn_text()
{
var my_name = '';
document.form1.mytext.value = document.form1.bar.click();
}

Any Suggestions please.

Kind Regards,
Pai.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
Srikanth Pai <sp**@immunetolerance.org> writes:
hello Irn,
That would be LRN (my initials) :)
Thanks for your reply, on the devdex.com forum.
I don't know what the devdex.com forum is, this is a Usenet newsgroup
and it is not affiliated with devdex.com.
Actually, when I click on tbe browse button <input type=file name=bar>.
I would like the selected file name to be inseted in a text field which
is placed next to the button.
You can do this with the onchange handler on the file input. See below
I tried using a onclick event but it gets fired before the dialog box is
displayed so i cannot retrieve the name

<input type =text name=mytext>
<input type=file name=bar onclick='fn_test()'>.


<form ...>
<input type="text" name="mytext">
<input type="file" name="bar"
onchange="this.form.elements.mytext.value = this.value">
</form>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4

Hello irn,

<input type="file">

does not have a event onchange.

Kind Regards,
Pai.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5
In article <sm**********@hotpop.com>, Lasse Reichstein Nielsen <lr*@hotpop.com>
writes:
<form ...>
<input type="text" name="mytext">
<input type="file" name="bar"
onchange="this.form.elements.mytext.value = this.value">
</form>


Works in IE6.0, Opera 7, fails in Mozilla 1.4, Firebird 0.6.1and Netscape 7.02.
--
Randy
All code posted is dependent upon the viewing browser
supporting the methods called, and Javascript being enabled.
Jul 20 '05 #6
hi************@aol.com (HikksNotAtHome) writes:
Works in IE6.0, Opera 7, fails in Mozilla 1.4, Firebird 0.6.1and
Netscape 7.02.


True. Since my first hint was IE only, I didn't say that the second
was only tested in IE6 and Opera 7. By mistake.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

24 posts views Thread by Kelly | last post: by
17 posts views Thread by Peter Duniho | last post: by
5 posts views Thread by charles | last post: by
1 post views Thread by sunita | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.