www.webdeveloper.com
Results 1 to 2 of 2

Thread: Javascript Error...

Hybrid 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]

  2. #2
    Join Date
    Feb 2010
    Location
    Amsterdam
    Posts
    174
    I am getting some more errors, why do you sometimes use a semicolon at the end of a line and sometimes not?

    i played with it a bit but getting "missing ( before formal parameters": http://www.webdevout.net/test?02u

    at least your missing the switch(..) inside your changeFiles function

    also your using a lot of with which is advised against: http://yuiblog.com/blog/2006/04/11/w...dered-harmful/

    i would rewrite the code without using the with statement and start building (and testing) your functions from there

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

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.14873 seconds
  • Memory Usage 2,921KB
  • Queries Executed 13 (?)
More Information
Template Usage (30):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (2)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (27):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./includes/functions_threadedmode.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates