www.webdeveloper.com
Results 1 to 6 of 6

Thread: document.forms.name is undefined

Threaded View

  1. #1
    Join Date
    Jan 2009
    Location
    127.0.0.1
    Posts
    126

    document.forms.name is undefined

    The error is the title 'TypeError: document.forms.sections_scopes_form is undefined' this one is more specific to my code. It is located in the function checkboxes_sections_scopes() as part of the if statement.

    If you want to copy and paste the code to see if for yourself you have to click a check box to get the program to throw the error.

    Below is enough of my source html and javascript to get the program to "work". I imagine that it is some kind of syntax error that I just can't see because I use the exact same DOM call in my function display_sections_scopes() where it works just fine.

    Code:
    <!DOCTYPE>
    <html>
    <head>
    	<meta charset="utf-8" />
    
    	<style type="text/css">
    	#wrapper()
    	
    		#content()
    			
    			
    	</style>
    		
    	
    	
    </head>
    <body>
    	<div id="wrapper">
    		<div id="content">
    			
    			<!-- The checkboxes for the Section Numbers and Scope Titles will appear in this table. -->
    			<div id="sections_scopes-div">
    				<form name="sections_scopes_form" method="get" action="" id="sections_scopes_form" enctype="multipart/form-data">
    				</form>
    			</div>
    			
    		</div>
    	</div>
    	
    	<!--Loading in the database functionality of the taffydb. For a quick tutorial http://www.taffydb.com/-->
    	<script type="text/javascript" src="taffy.js">
    	</script>
    	
    	<script type="text/javascript" language="javascript">
    		
    		/* This is the JavaScript database format. */
    		var sections_scopes = TAFFY([{"id":0, section:"05 53 00", scope:"Metal Gratings", in1:"mg-inclusion 1", in2:"mg-inclusion 2", in3:"mg-inclusion 3", in4:"mg-inclusion 4", ex1:"mg-exclusion 1", ex2:"mg-exclusion 2", ex3:"mg-exclusion 3", ex4:"mg-exclusion 4"}, {"id":1, section:"05 73 00", scope:"Decorative Metal Railings", in1:"dmr-inclusion 1", in2:"dmr-inclusion 2", in3:"dmr-inclusion 3", in4:"dmr-inclusion 4", ex1:"dmr-exclusion 1", ex2:"dmr-exclusion 2", ex3:"dmr-exclusion 3", ex4:"dmr-exclusion 4"}, {"id":2, section:"07 21 00", scope:"Thermal Insulation", in1:"ti-inclusion 1", in2:"ti-inclusion 2", in3:"ti-inclusion 3", in4:"ti-inclusion 4", ex1:"ti-exclusion 1", ex2:"ti-exclusion 2", ex3:"ti-exclusion 3", ex4:"ti-exclusion 4" }, {"id":3, section:"07 84 13", scope:"Penetration Firestopping", in1:"pf-inclusion 1", in2:"pf-inclusion 2", in3:"pf-inclusion 3", in4:"pf-inclusion 4", ex1:"pf-exclusion 1", ex2:"pf-exclusion 2", ex3:"pf-exclusion 3", ex4:"pf-exclusion 4"}]);
    
    		/*setting variables for while loops to iterate over the database*/
    		//x is used for looping through sections and scopes
    		var x = 0;
    		//y is used for looping through inclusions
    		var y = 0;
    		//z is used for looping through exclusions
    		var z = 0;
    		var num_sections = sections_scopes().max("id");
    		
    		/*Displays each Section Number and the Scope Title in succession beside a checkbox. The user can select each checkbox to be displayed with choices for inclusions and exclusions under each Section Number and Scope Title.*/
    		
    		function display_sections_scopes()
    			{
    				var x = 0;
    				while(x <= num_sections)
    				{
    					var section = sections_scopes({"id":x}).select("section");
    					var scope = sections_scopes({"id":x}).select("scope");
    					var text = " " + section + " " + scope + "\n";
    					
    					var input = document.createElement("input");
    					input.setAttribute("type", "checkbox");
    					input.setAttribute("name", section);
    					input.setAttribute("onclick", "checkboxes_sections_scopes()");
    					var form = document.forms['sections_scopes_form'];
    					form.appendChild(input);
    					
    					var label = document.createElement("label");
    					label.setAttribute("for", section);
    					form.appendChild(document.createTextNode(text));
    					
    					x++;
    				}
    			};
    
    		//Retrieving the number of inclusions per section/scope
    		function get_num_inclusions(input_id)
    			{
    				var count_in = 0;
    				var y = 0;
    				section = input_id;
    				document.write(section);
    				while(y)
    					{
    						var inclusion = "in" + y;
    						document.write("Inclusions: " + inclusion);
    						sections_scopes({section:"section"}).get(inclusion);
    						y++;
    						count_in++;
    					}
    				return count_in;
    			}
    		
    		//Retrieving the number of exclusions per section/scope
    		function get_num_exclusions(input_id)
    			{
    				var count_ex = 0;
    				var z = 0;
    				section = input_id;
    				document.write(section);
    				while(z != -1)
    					{
    						var exclusion = "ex" + z;
    						sections_scopes({section:"section"}).get(exclusion);
    						z++;
    						count_ex++;
    					}
    				return count_ex;
    			}
    
    		/*Displays a list of the inclusions and exclusions of each Section Number/Scope Title if the Section Number/Scope Title checkbox is selected. Each inclusion or exclusion is accompanied by a check box. This check box is to include or exclude the selection(inclusion or exclusion) from the final document.
    		*/
    
    		//Showing or hiding the inclusions and exclusions based on the status of the section/scope checkbox
    		function checkboxes_sections_scopes()
    			{
    			var x = 0;
    				while(x <= num_sections)
    					{
    						var input_id = sections_scopes({"id":x}).select("section");
    						document.write("Input ID:" + input_id);
    						
    						if(document.forms.sections_scopes_form.input_id.checked == true)
    							{
    								document.write("display inclusions");
    								display_inclusions_exclusions(input_id);
    							}
    						else
    							{
    								document.write("hide inclusions");
    								hide_inclusions_exclusions(input_id);
    							}
    					}
    			};
    
    		//Retrieving the correct inclusions and excluions to display with their respective section/scope
    		function display_inclusions_exclusions(input_id)
    			{
    				document.write("\nInput ID: " + input_id);
    				var x = 0;
    				var y = 0;
    				var z = 0;
    				while(x <= num_sections)
    				{
    					var section = sections_scopes({"id":x}).select("section");
    					if(input_id == section)
    					{
    						num_inclusions = get_num_inclusions(input_id);
    						num_exclusions = get_num_exclusions(input_id);
    						
    						while(y <= num_inclusions)
    						{
    							//print in table below respective section and scope with a heading of "Inclusions"
    							var inclusion = "in" + y;
    							document.write(inclusion)
    							document.write(sections_scopes({section:"section"}).select(inclusion));
    							y++;
    						}
    						while(z <= num_exclusions)
    						{
    							//print in table below respective section and scope with a heading of "Exclusions"
    							var exclusion = "ex" + z;
    							document.write(sections_scopes({section:"section"}).select(exclusion));
    							z++;
    						}
    					}
    				}
    			};
    
    		function hide_inclusions_exclusions(input_id)
    			{};
    	
    	
    	document.onload = display_sections_scopes();
    	</script>
    </body>
    </html>
    Thanks for the help in advance. If you have any questions or need some clarification please let me know.
    Last edited by spotted zebra; 08-01-2012 at 11:48 AM. Reason: clarifications
    post your flippin' source code! don't explain it in English when it is already written in 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

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.14269 seconds
  • Memory Usage 3,230KB
  • Queries Executed 14 (?)
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
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (6)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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 (74):
  • 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_postinfo_query
  • fetch_postinfo
  • 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
  • bbcode_parse_start
  • postbit_imicons
  • 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