dinesh707
dinesh707

Reputation: 12592

How to get the event onText Change of a input (type ="file") box

I have the following code

<input id="url" type="text" value="blab.ogg"/>
<input id="fileUrl" type="file" size="1" onblur="document.getElementById('url') =  this.value"/> 

i need to set the same text in fileUrl, into url if somebody inserts a file by file chooser.

what is the event which triggers the dynamic change in text in input.

Upvotes: 0

Views: 73

Answers (1)

Mihai Matei
Mihai Matei

Reputation: 24276

Try onchange event:

<input id="fileUrl" type="file" size="1" 
onchange="document.getElementById('url').value =  this.value"/>

Also, as you can see, you should assign the file input value to the value of the url input:

document.getElementById('url').value =  this.value

Upvotes: 1

Related Questions