I have successfully created an HTML form that gets a file from a user and also allows giving a name for the file. I have also succeeded in creating a javascript function that can get the name of the file from the upload stream, and only the name (without the path and extension). Problem is, I somewhat do not manage to change the input that's there for renaming the upload like I want to. Here is the working function with two demonstrative alerts:
<script type="text/javascript">
function updateInput(val) {
som = val.split('\\')[val.split('\\').length - 1];
som = som.split('.')[0];
alert('Hey 1');
fileName.value = som;
alert('Hey 2');
}; </script>
"Hey 1" alert is displayed and it's alright. "Hey 2" is actually not displayed! fileName is both the name and id of the input for the file's name, I DID try using document.getElementById('fileName').value = ... but with no luck.
Declaration of fileName:
<input type="text" runat="server" id="fileName" name="fileName" />
The javascript is located in the code under this input. The uploadImage input (which is type of file) is above this input. (Yes, the event is called and som gets the value I want it to have)
*I am trying to change the value of an input:text element. I will try the var thing.
THANK YOU IF YOU CAN HELP!
valueof aninput:fileelement? Or am I misreading? Anyways, why do you expectfileName.value = som;to work?varin front ofsomso it's declared as a local variable. Also, what is thefileNamevariable? It isn't declared here so we don't know what it is.fileNamevariable? How do you get it?