I want to fill the HTML form with JavaScript. The following JavaScript code
document.forms[‘theForm’][‘city’].value = ‘Ottawa’
fills the HTML form OK as follows.
<input type=”text” name=”city” value=”Ottawa”>
However, the following JavaScript
document.forms[‘theForm’][‘uploadfile’].value = ‘/Users/gss/Desktop/ToDo.txt’
does not fill the form to upload a file next to question “Choose File”. What I want is the following, but the “value” part is not accepted for some reason.
<input type=’file’ name=’uploadfile’ value=’/Users/gss/Desktop/ToDo.txt’/>
Even if I directly hard-code the “value” part in HTML itself, the web browser does not show it. Could anyone tell me why and how to make the JavaScript work? Thanks in advance!!!