473,382 Members | 1,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

<input type file> Focus

3
hiya all
i would like to ask some help for a little javascript, here's my problem:
i have a html page with a <input type="file"> box, problem is i don't want the user to be able to write on the text field, he must use the browse button.
i tried a lot of codes but no one works for both IE and firefox
i tried to use onclick="blur",m but in that case the field and "browse button" didn't work

here's what i've done:

<form name="form1">
<input type="file" name="insertdoc" onclick="document.form1.otherinput.focus()">
<input type="hidden" name="otherinput">
</form>

works for firefox, you cannot write on the field, but browse button works well, problem is, this code don't work on IE error says: "can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus" well...IE, i hate you!

i tried to send my focus to another text field, in that case, browse button don't work....anyone with an idea how i can do this to work on IE?
thanks a lot for your help

Rei
Jan 11 '07 #1
6 8082
acoder
16,027 Expert Mod 8TB
I can understand your problem and frustration. I'm not sure how you can solve the problem for IE, but no matter what they type into the input box, you can always check that the file exists on the server side. It just means a wasted trip to the server if the file doesn't exist and hence cannot be uploaded.
Jan 11 '07 #2
reiyel
3
problem is, i really need it to be done that way :(
the user can't write on that textfield >_<
Jan 11 '07 #3
Took some thought but here is what I have:


<form name="form1">
<input type="file" name="insertdoc" onkeydown="return false">
<input type="hidden" name="otherinput">
</form>

Hope it helps :)
Jan 14 '07 #4
There is a very easy way past this by the way, which is pasting a value into it. It is all I could think of for IE.
Jan 14 '07 #5
reiyel
3
Took some thought but here is what I have:


<form name="form1">
<input type="file" name="insertdoc" onkeydown="return false">
<input type="hidden" name="otherinput">
</form>

Hope it helps :)
that works, it's really cool.
thank you very much everyone for your great help!! (^_^)(_ _)(^_^)
Jan 15 '07 #6
acoder
16,027 Expert Mod 8TB
that works, it's really cool.
thank you very much everyone for your great help!! (^_^)(_ _)(^_^)
Good work johnhjohn for working that out. I didn't think about using onkeydown.
Remember reiyel that this isn't completely foolproof as john pointed out.
Jan 15 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Don | last post by:
Is there some way to populate the "Browse" box for a <input type=file...> with a default value? I can do it for <input type=text...>, but can't seem to do it for <input type=file...>. Any ideas?...
4
by: Bhavin | last post by:
Hi I'm trying to input image file using this synax. <input type=file name="tx_file" accept="image/*" class=boxText> But when open file dialouge appears, it shows all the file and user can select...
0
by: Reza | last post by:
Hello I have a html control, <input type= file ...> and 1. I want the user to select files always from a set location but not sure how or even is this possible 2. If it is possible, can it set...
1
by: myahact | last post by:
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...
1
by: Axe | last post by:
Here's the problem: I've got an ASP.NET (C#) web page that has a single <input type=file> control on it for uploading a file. The way the code works is that the uploaded file is then parsed for...
2
by: Evgeny Zoldin | last post by:
Hi ALL. I need to simulate send POST data ( - file upload) as it was submitted in Browser. In C# I create instanse of IE, navigate to page with the form, fill in the fields and try to Submit by...
4
by: SammyBar | last post by:
Hi all, I wonder is it possible to upload the content of an <imgfield to a server. The content of the <imgwas downloaded from a web site different from the one it should be uploaded. The image...
1
by: mishrarajesh44 | last post by:
hi all, i am writting a program to update the record in the mysql databqse, using php. I hav designed the 'update form' totally same as my 'add form' so that by entering the mobile no. of...
5
by: magix | last post by:
Hi, with: <Input type="file"...> it will let the user to click to "browse" button to browse for files, question is how can I limit the file type to be only jpg and gif extension, when the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.