Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding or shrink the textbox for input type=file 2

Status
Not open for further replies.

xpblueScreenOfDeath

Programmer
Sep 1, 2004
87
Is there a way to shrink the textbox for input type=file, so that it is almost completely hidden or hidden? I only want the browse button to be showing. I'll be using javascript to add the file name to a listbox, but I don't need the textbox to be showing.

I tried the code below but it only seem to work in IE and not firefox.

Code:
<INPUT type=file style="Width: 0px">
 

You could use something like this:

Code:
<html>
<head>
</head>
<body>
	<form>
		<div style="owerflow:hidden;">
			<input type="file" name="myFile" style="position:absolute; width:200px; left:-120px;" />
		</div>
	</form>
</body>
</html>

The value for "left" might need to be different per browser, but you should be able to do this fairly easily with JS.

Hope this helps,
Dan

 
Is there a way to solve this problem without having to do an absolute postion? With that solution my contents doesn't flow right. The browse button is always covering my content to the left of it unless I put in a postion for the input control. Thanks for the suggestion.
 
Actually, the code provided by Dan should work equally good with relative positioning:
Code:
<html>
<head>
</head>
<body>
    <form>
        <div style="overflow: hidden;">
            <input type="file" name="myFile" style="position: relative; width: 200px; left: -120px;" />
        </div>
    </form>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top