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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display end of text box

Status
Not open for further replies.

SaRiD

Programmer
Apr 19, 2003
45
Hi

When uploading a file using <input type="file"> it brings up a textbox and a browse button.

Once you have browsed your computer and found the file you are looking for it then enters the path into the textbox.

When the path is inserted into the textbox it shows the text at the start of the path. E.g. c:\folder\next...
if the full path was: c:\folder\next folder\thisfile.txt and the textbox wasn't wide enough the user could only see the start of the path.

The question is:
Is there a way to have it show the end of the file path? So just make it focus the textbox to the end instead of the beginning.

Make sense?
 
Maybe you will have some luck with the HTML size attribute that you can add to the input directly...

Code:
<input type="file" [b]size="30"[/b]>

I haven't found a reliable method to set the width using CSS (non-inline).

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
Normally I wouldn't worry about it but a Client requested if it could be done so I thought I would try and find out.

It's a look and feel thing as to why the size of the input box has to be small.
 
I created another solution to fix the problem.

I just created a div tag just below the text box and ran the following code:

Code:
<script>
function DisplayFilename(filename, objFilename) {
  obj = document.getElementById(objFilename);
  var x = 0;
  var len = 0;
  
  x = filename.indexOf("\\");
  while(x > 0) {
    x++;
    len = filename.length;
    filename = filename.substr(x, (len-x));
    x = filename.indexOf("\\");
  }
  obj.innerHTML = filename;
}
</script>

Which takes the filename and displays it in the div tag.

I suppose if anyone wanted to be really clever they could do some stylesheets and have it appear directly overtop of the inputbox.

Cheers for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top