I can't seem to figure why it will not return the file's name and extension.
It is suppose to return the XML file's name and extension in an alert message.
It appears that this part of the code is not working. I deduced this by just declaring an alert at the beginning of the called function (msg()), and with the onClick function of the button. The onClick function works, but the msg() is not being called or it doesn't know what to do.
"document.forms["myForm"]["libxml"].value"
Code:
<html>
<head>
<script type="text/javascript">
function msg(var URL)
{
if (URL==null || URL=="" || !fileTypeParser(URL))
return('Please enter a XML file');
if (fileTypeParser(URL))
return(URL);
else
return('You have the wrong data type');
}
function fileTypeParser(var URL)
{
var array = URL.split(".");
if(array[1]=="xml")
return true;
else
return false;
}
</script>
</head>
<body>
<!-- This code is to simply out put the file's name and extension as an alert -->
<form name="myForm">
<input type="file" name="libxml" accept="text/xml" />
<input type="button" value="Submit" onclick="alert(msg(document.forms["myForm"]["libxml"].value))"/>
</form>
</body>
</html>
Any help would be greatly appreciated.
Thanks.