I have the following code in my view, I need to store name of selected file from the input file in the textbox above, I have tried the following JS script but I get no results

@Html.TextBoxFor(model => Model.helpVM.str1, htmlAttributes:new { id="inputId", @class = "form-control" })

<div class="col-md-4">
    <a href="#" onclick="document.getElementById('fileID').onchage(); return false;" class="btn btn-info">Choisir fichier</a>
     <input type="file" name="FileUpload" accept=".txt" data-input="false"  id="fileID" style="visibility: hidden;" />
 </div>  


            <script type="text/javascript">
                var filename = $('#fileID').val();
                document.getElementById("fileID").onchange = function () {
                    document.getElementById("inputId").value = filename
                };

In fire bug i get this error TypeError: document.getElementById(...).onchange is not a function

Related posts

Recent Viewed