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

JavaScript events

Status
Not open for further replies.

bendjoe

Programmer
Feb 12, 2008
3
US
I am new to JavaScript see the code below
UploadBox.onchange="text"+addFileUploadBox.lastAssignedId+".value=this.value";

This doesn't look like the right way of doing this. Could some one tell me how I can do this. I also tried using setAttribute but no success.
 
I am trying to upload files from the client machine to the server.

So my page will load with one input box and one upload box(input with type=file)
I could do it just with an input box with type file but for the sake of styling issues I have to use an input box in sync with an upload box.

This approach works with the controls that are already on the page. My upload page can add upload fields dynamically. when such upload fields are dynamically added I have to specify the onchange event so as the file selection is done in the upload box the value in the uploadbox is transferred into the input box.
uploadbox.onchange->inputbox.value=this.value like that.As the upload and input boxes are created dynamically their names will also be dynamic, that is one additional issue I am facing. Any comments?



 
I don't know that I completely understand what you're trying to do, however since it seems like you're trying to mix javascript and input boxes of type file then you're probably gonna hit a brick wall. The contents of an input box of type file cannot be modified by javascript.

-kaht

 
Hi

kaht said:
The contents of an input box of type file cannot be modified by javascript.
I think bendjoe only wants to extract the [tt]value[/tt], not to modify it. Anyway, FireFox certainly not gives out the full value to JavaScript, only the file name part.

Neither I am sure I understand the requirements, but I think Peter-Paul Koch's article Styling an input type="file" could give some hint.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top