Javascript pick list returns File Not Found error

I have a simple JS pick list (included below) that is modeled on another I wrote that works correctly. When I select an item in the list and click 'Go', I get a page with 'file:///.../undefined' displayed in the location bar in IE and Firefox; in Firefox the error console shows:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Error: uncaught exception: [Exception... "File error: Not found"  nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)"  location: "JS frame :: file:///F:/MSProject%20Web%20Page/test2.html :: go :: line 9"  data: no]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The target file is in the directory in question, but the error message suggests that something is wrong with the code. I need to solve this ASAP for a deliverable that is becoming overdue. Any help would be appreciated.
<HTML>
<HEAD>Test</HEAD>
<BODY>
This is a test pick list:
 
<script language="JavaScript" type="text/javascript">
function go(){
if(document.selecter.select1.options[document.selecter.select1.selectedIndex].Value !="none"){
location = document.selecter.select1.options[document.selecter.select1.selectedIndex].Value
        }
    }
</script>
<script language="JavaScript" type="text/javascript">
<!--
document.write('<form name="selecter"><select name="select1" size=1>');
document.write('<option value ="test.html">Test Doc');
document.write('</select>');
document.write('<input type="button" Value="Go" onclick="go()">');
document.write('</form>');
//end hiding contents-->
</script>
 
</body>
</html

Open in new window

dgmoore1Asked:
Who is Participating?
 
Michel PlungjanConnect With a Mentor IT ExpertCommented:
JS is case sensitive
.value instead of .Value
0
 
Michel PlungjanIT ExpertCommented:
I would write it like this

<html>
<head>Test</head>
<script language="JavaScript" type="text/javascript"><!--
function go(theForm){ 
  var loc = theForm.select1.options[theForm.select1.selectedIndex].value;
  if (loc!="none") window.location = loc;
  return false;
}
window.onload=function() {
  document.forms[0].select1.selectedIndex=0;
}
// --></script>
 
<body>
This is a test pick list:
 
<script language="JavaScript" type="text/javascript"><!--
var text = '<form onSubmit="return go(this)">'+
'<select name="select1" size=1>'+
'  <option value ="none">Please select</option>'+
'  <option value ="test.html">Test Doc</option>'+
'</select>'+
'<input type="submit" value="Go" />'+
'</form>';
document.write(text);
// -->
</script>
 
</body>
</html>

Open in new window

0
 
dgmoore1Author Commented:
I knew it was something simple - I'm editing in Notepad and it's hard to spot U/C "V" vs. L/C "v", especially with eyes as old as mine.  Many thanks!!
0
 
Michel PlungjanIT ExpertCommented:
Suggestion: test in Firefox - the javascript console would most likely tell you the error
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.