www.webdeveloper.com
Results 1 to 2 of 2

Thread: Javascript Error...

Threaded View

  1. #1
    Join Date
    May 2009
    Location
    Dominican Republic
    Posts
    2

    Javascript Error...

    I am getting object expected when the combo "menuTopics calls the function onchange="changeSubjects()", I cant find whats the problem.

    Here is the code:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>OEE</title>
    <link href="pageCSS.css" rel="stylesheet" type="text/css">
    <script type="text/JavaScript">
    //new Option("text","value")
    //this code changes menus
    function nullOptions(aMenu){
    /*var tot=aMenu.options.length
    for (i=0;i<tot;i++)
    {
    aMenu.options[i]=null
    }*/
    aMenu.options.length=0;
    }
    
    //Rewrites the text and values
    function MySubject-1-1(aMenu){
    nullOptions(aMenu)
    with (aMenu){
    	options[0]=new Option("Select a Line","none");
    	options[1]=new Option("BM 1","1");
    	options[2]=new Option("BM 2","2");
    	options[0].selected=true
    }
    }
    
    function MySubject-1-2(aMenu){
    nullOptions(aMenu)
    with (aMenu){
    	options[0]=new Option("Select a Line","none");
    	options[0].selected=true
    }
    }
    
    
    function MyTopics1(aMenu){
    nullOptions(aMenu)
    with (aMenu){
    	options[0]=new Option("Blow Molding","1");
    	options[1]=new Option("Receptal","2");
    	options[0].selected=true
    }
    }
    
    
    function go(aMenu){
    if (aMenu.options.value!="none")
    {
    location=aMenu.options[aMenu.selectedIndex].value
    } 
    else
    aMenu.options[0].selected=true;
    
    }
    
    function setUp(){
    //if (navigator.appName.indexOf("Microsoft")>-1)
    {
    document.form1.menuTopics.options[0].selected=true;
    document.form1.menuSubjects.options[0].selected=true;
    document.form1.menuFiles.options[0].selected=true;
    
    
    }
    }
    
    function changeSubjects(){
    aMenu=document.form1.menuSubjects
    aMenu2=document.form1.menuFiles
    aMenu3=document.form1.menuTopics
    with  (aMenu3){
    switch (selectedIndex) {
    case 0:
    nullOptions(aMenu)
    nullOptions(aMenu2)
    aMenu.options[0]=new Option("Lines appear here","none")
    aMenu3.options[0].selected=true;
    history.go(0)
    break    
    case 1:
    //computer stuff
    nullOptions(aMenu)
    nullOptions(aMenu2)
    aMenu2.options[0]=new Option("Lines appear here","none")
    aMenu2.options[0].selected=true;
    MyTopics1(aMenu)
    break
    }
    }
    
    }
    
    
    function changeFiles(){
    aMenu=document.form1.menuSubjects
    aMenu2=document.form1.menuFiles
    aMenu3=document.form1.menuTopics;
    
    
    if (aMenu3.selectedIndex==1)
    {
    with (aMenu){
    case 0:
    	aMenu2.options.length=0;
    	aMenu2.options[0]=new Option("Lines appear here","none")
    	aMenu2.options[0].selected=true;
    	history.go(0)
    break
    case1:
    	MySubject-1-1(aMenu)
    break
    case1:
    	MySubject-1-2(aMenu)
    break
    }
    }
    }
    
    }
    
    
    </script>
    
    <script type="text/JavaScript">
    <!--
    
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    
    function DoNav(theUrl) {
    	document.location.href = theUrl;
    }
    
    //-->
    </script>
    <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
    </head>
    
    <body background="images/main-bg.gif">
    <table width="100&#37;" border="0" cellspacing="0" cellpadding="0">
    .
    .
    .
    <form id="form1" name="form1" method="post" action="asp-add-equipment.asp">
                        <table border="0" cellspacing="0" cellpadding="0" bgcolor="#F0F0F0">
                          <tr class="Normal-Text-2">
                            <td colspan="10" valign="bottom" class="Form-Text-1"><table width="700" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td width="50">Building</td>
                                <td width="160"><select name="menuTopics" id="menuTopics" onchange="changeSubjects()" size="1" style="width:160px">
                                  <option value="none"> Buildings appear here </option>
                                  <option value="none"> Hospira Building 1</option>
                                </select></td>
                                <td width="16">&nbsp;</td>
                                <td width="40">Area</td>
                                <td width="160"><select name="menuSubjects" id="menuSubjects" onchange="changeFiles()" size="1" style="width:160px">
                                  <option value="none"> Areas appear here </option>
                                </select></td>
                                <td width="20"><img src="images/spacer.gif" width="20" height="16" /></td>
                                <td width="40">Line</td>
                                <td width="160"><select name="menuFiles" id="menuFiles" onchange="go(this)" size="1" style="width:160px">
                                  <option value="none"> Lines appear here </option>
                                </select></td>
                                </tr>
                            </table></td>
                            </tr>
                          <tr class="Normal-Text-2">
                            <td colspan="10" valign="bottom"><img src="images/spacer.gif" width="700" height="16" /></td>
                          </tr>
                          <tr class="Normal-Text-2">
                            <td colspan="10" valign="bottom"><table width="700" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td width="36" valign="bottom"><span class="Form-Text-1"> Name</span></td>
                                <td width="100" valign="bottom"><input type="text" name="Name" id="Name"  style="width:100px"/></td>
                                <td width="20" valign="bottom"><img src="images/spacer.gif" width="20" height="16" /></td>
                                <td width="37" valign="bottom"><span class="Form-Text-1">Status</span></td>
                                <td width="82"><table width="82" border="0" cellspacing="0" cellpadding="0">
                                  <tr class="Small-Text-1">
                                    <td width="38" align="center">Active</td>
                                    <td width="44" align="center">Inactive</td>
                                  </tr>
    .
    .
    Last edited by Kor; 02-24-2010 at 05:00 AM. Reason: wrap the code [code][/code]

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles