Hey guys. I’m a first poster here and pretty new to JavaScript.
I’ve been working on some functions and they work been when I’m calling them from the *.html file. But the trouble starts when I add the scr code…
[CODE]<script type=”text/javascript” src=”case.js”></script>
This is my case.js code.
[CODE]function check_input()
{
// Get user input from text field in form id of f
var entry = document.forms[0].textfield.value;
// Compare input and display an appropriate message
if(entry.toLowerCase() == “castle”){
alert(“Accepted”);
{
else alert(“Refused”);}
}
}
And this is my html code…
[code=html]<html>
<head>
<title>Untitled Document</title>
<script type=”text/javascript” src=”case.js”>
</script>
</head>
<body>
<input type=”text”>
<input type=”button” value=”Check Input” onClick=”check_input()”>
</body>
</html>
I don’t understand what the trouble is :S I mean I’ve tested functions when they’re inside the html file but when I seperate them, it just doesn’t work!
Kind regards, James.