Okay, I get what you're saying but you are talking about <input type="file">'s right?
You click on browse or find and it opens a window to select a file then once selected the path to the file goes into the text box. Javascript can't change this value because if you could do that with javascript, then the file at that path can then be sent to the server so a malicious coder could ask for c:\passwords.txt and that file would be sent to the website without the user knowing.
You can change the values of text boxes easily enough but not file inputs.
- Code: Select all
<script type="text/javascript">
function changeTexts(value) {
var inputBoxes = document.getElementByTagName(''input');
for (i = 0; i< inputBoxes.length; i++){
if (inputBoxes[i].type == 'text') {
inputBoxes[i].value = value;
}
}
}
</script>
<input type="text" value="" name="hi" onchange="changeTexts(this.value)"/>
<input type="text" value="" name= "hi1" />
<input type="text" value="" name="hi3" />