File Open Dialog Box

P

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
 
L

Lasse Reichstein Nielsen

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
 
S

Srikanth Pai

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.
 
L

Lasse Reichstein Nielsen

Srikanth Pai said:
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
 
S

Srikanth Pai

Hello irn,

<input type="file">

does not have a event onchange.

Kind Regards,
Pai.
 
L

Lasse Reichstein Nielsen

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
 

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
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top