www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Undefined Error

  1. #1
    Join Date
    Jul 2011
    Posts
    3

    resolved [RESOLVED] Undefined Error

    For some reason my variable is coming put with undefined. I have looked and looked and i am sure it is obvious but i cannot figure it out.

    Can someone please tell me how much of an amateur move i am making

    Code:
    <script type="text/javascript">
    function addtube(){
            var count = parseInt(document.getElementById("tube_count").value);
    		var temp1 = document.getElementById("abcd");
    		//alert(temp1.rows.length);
    		//alert(count);alert(temp1);
    		temp1.insertRow(temp1.rows.length);
    		 temp1.rows.item(temp1.rows.length - 1).insertCell(0);
    		 var xx	=	temp1.rows.length -1 ;
    		
    		 count = count+1;
    		 var sHTML = document.getElementById("Quote_req_lines").innerHTML;
    		 sHTML = sHTML.replace('name="Quote_req1"','name="Quote_req'+count+'"');	
    		 sHTML = sHTML.replace('id="Quote_req1"','id="Quote_req'+count+'"');
    		 
             sHTML = sHTML.replace('name="remove_window1"','name="remove_window'+count+'"');	
    		 sHTML = sHTML.replace('id="remove_window1"','id="remove_window'+count+'"');	
    		 sHTML = sHTML.replace('onclick="remove(1);"','onclick="remove('+count+');"');	
    		 		 
    		 sHTML = sHTML.replace('name="height_feet1"','name="height_feet'+count+'"');	
    		 sHTML = sHTML.replace('id="height_feet1"','id="height_feet'+count+'"');	
    
             sHTML = sHTML.replace('name="height_inches1"','name="height_inches'+count+'"');	
    		 sHTML = sHTML.replace('id="height_inches1"','id="height_inches'+count+'"');	
    		 
    		 sHTML = sHTML.replace('name="width_feet1"','name="width_feet'+count+'"');	
    		 sHTML = sHTML.replace('id="width_feet1"','id="width_feet'+count+'"');	
    		 
    		 sHTML = sHTML.replace('name="width_inches1"','name="width_inches'+count+'"');	
    		 sHTML = sHTML.replace('id="width_inches1"','id="width_inches'+count+'"');
    		 
    		 sHTML = sHTML.replace('name="flash_select1"','name="flash_select'+count+'"');	
    		 sHTML = sHTML.replace('id="flash_select1"','id="flash_select'+count+'"');
    		 
    		 sHTML = sHTML.replace('name="select_color1"','name="select_color'+count+'"');	
    		 sHTML = sHTML.replace('id="select_color1"','id="select_color'+count+'"');
    		 
    		 
    		 temp1.rows.item(temp1.rows.length-1).cells.item(0).innerHTML=sHTML;
    	//alert(sHTML);
    		 //temp.rows.item(temp.rows.length-1).cells.item(0).innerHTML=sHTML;
     		document.getElementById("tube_count").value = count;
    		
    		count ++;
    		
    }
    function testing1(){
    	var tube_line_count = document.getElementById("tube_count").value;
    	var GrandTotalTubes = 0;
    	var TotalCost = 0;
    	for(var i=1; i<=tube_line_count; i++){
    		var HeightFeet = document.getElementById("height_feet"+i).value;
    		if(HeightFeet ==''){
    		  HeightFeet = 0;
    		}
    		var HeightInches = document.getElementById("height_inches"+i).value;
    		if(HeightInches ==''){
    		HeightInches = 0;
    		}
    		var TotalHeight = (parseFloat(HeightFeet)*12)+parseFloat(HeightInches)-5;
    // changed divide to multiply;
    // changed parseint to parse float to handle decimals;
    		alert(HeightFeet + ' Height Feet');
    		var WidthFeet = document.getElementById("width_feet"+i).value;
    		if(WidthFeet ==''){
    		  WidthFeet = 0;
    		}
    		var WidthInches = document.getElementById("width_inches"+i).value;
    		if(WidthInches ==''){
    		WidthInches = 0;
    		}
    		var TotalWidth = (parseFloat(WidthFeet)*12)+parseFloat(WidthInches)-5;
    // changed divide to multiply;
    // changed parseint to parse float to handle decimals;
    		TotalLength = (TotalHeight + TotalWidth)*2;
    // corrected to multiply both values * 2;
    		alert(TotalLength + ' Total Length');
    		var TotalHeightTubes = Math.ceil(TotalHeight/48);
    // changed round to ceil to round the figure up;
    		var TotalWidthTubes = Math.ceil(TotalWidth/48);
    // changed round to ceil to round the figure up;
    		var TotalTubes = (TotalWidthTubes + TotalHeightTubes)*2;
    // corrected to multiply values *2;
    		var HeightTubeSize = TotalHeight/TotalHeightTubes;
    		var WidthTubeSize = TotalWidth/TotalWidthTubes;
    		alert(TotalHeight + ' Total Height');
    		alert(TotalWidth + ' Total Width');
    		alert(TotalHeightTubes +' Total Height Tubes');
    		alert(TotalWidthTubes +' Total Width Tubes');
    		alert(TotalTubes +' Total Tubes');
    		var GrandTotalTubes = GrandTotalTubes+TotalTubes;
    		alert(GrandTotalTubes +' Grand Total Tubes');
    		var TransformerLoadLength = (Math.ceil(TotalLength/12))+TotalTubes;
    // changed round to ceil to round the figure up;
    		alert(TransformerLoadLength +' Transformer Load Length');
    		var Tranformer_load_value = document.getElementById("Transformer_Load").value;
    		var myString = new String(Tranformer_load_value); 
    		var myArray_trans_load = myString.split(','); 
    		alert(Tranformer_load_value + ' Transformer load value');
    		alert(myString + ' My String');
    		alert(myArray_trans_load[0] + ' My Array 1');
    		alert(myArray_trans_load[1] + ' My Array 2');
    		//alert(myArray[1] + ' My Array');
    		var variable1 = TransformerLoadLength/myArray_trans_load[0];
    		var variable1RoundUp = Math.ceil(variable1);
    // changed round to ceil to round the figure up;
    		var variable2 = TransformerLoadLength/myArray_trans_load[1];
    		var variable2RoundUp = Math.ceil(variable2);
    // changed round to ceil to round the figure up;
    		//alert(variable1 + ' variable1');
    		//alert(variable2 + ' variable2');
    		alert(variable1RoundUp + 'variable1 rounded');
    		alert(variable2RoundUp + 'variable2 rounded');
    		var Transformertype_field_value = document.getElementById("Transformer_Type").value;
    		var myString1 = new String(Transformertype_field_value); 
    		var myArray_trans_type = myString1.split(','); 
    		//alert(myArray_trans_type[0]);
    		if(variable1RoundUp <= variable2RoundUp){
    		 var TranformerType = myArray_trans_type[0];
    		}
    		else{
             var TranformerType = myArray_trans_type[1];
    		}
    		//changed to round up to reflect correct calc
    		alert(TranformerType + ' Transformer Type');
    		if(variable1RoundUp<variable2RoundUp){
    		var NumberOfTransformers = variable1RoundUp;
    		}
    		if(variable2RoundUp<variable1RoundUp){
    		var NumberOfTransformers = variable2RoundUp;
    		}
    		alert(NumberOfTransformers + ' Number of Transfomers');
    		var CostPerTube = document.getElementById("Cost_per_tube").value;
    		var TubeSupportsPerTube = document.getElementById("Tube_Supports_per_tube").value;
    		var CostPerTubeSupport = document.getElementById("Cost_per_Tube_Support").value;
    		var GTOWirePerTube = document.getElementById("GTO_Wire_Per_Tube").value;
    		var CostPerGTOWire = document.getElementById("Cost_per_GTO_wire").value;
    		var EndCapsPerTube = document.getElementById("End_caps_per_Tube").value;
    		var CostPerEndCap = document.getElementById("Cost_per_End_Cap").value;
    		var Flashing_selected = document.getElementById("flash_select"+i).value;
    		if(Flashing_selected == 'Yes'){
    			Flashing_upgrade_value = document.getElementById("Flashing_upgrade_cost").value;
    		}
    		else{
    			Flashing_upgrade_value = 0;
    		}
    		//alert(Flashing_upgrade_value);
    		//we need to define the value. Because we don't have the value of this
    		var Tranformer_field_value = document.getElementById("Transformer_Cost").value;
    		var Transformer_Cost_Value = Tranformer_field_value.split(','); 
    		if(TranformerType == myArray_trans_type[0]){
    			var TransformerCost = Transformer_Cost_Value[0];
    		}
    		else{
    			var TransformerCost = Transformer_Cost_Value[1];
    		}
    		alert(TransformerCost + ' Transformer Cost');
    		var TotalCostWindow = parseFloat(TotalTubes*CostPerTube)+parseFloat(TotalTubes*TubeSupportsPerTube*CostPerTubeSupport)+parseFloat(TotalTubes*GTOWirePerTube*CostPerGTOWire)+parseFloat(TotalTubes*EndCapsPerTube*CostPerEndCap)+parseFloat(NumberOfTransformers*TransformerCost);
    		//Replacing value to the total_cost field
    		//document.getElementById("total_cost").value = TotalTubes;
    		var TotalCost = TotalCost+TotalCostWindow;
    	}
    	//var TotalCost_RoundUp_Value = Math.round(TotalCost);
    	document.getElementById("total_cost").value = TotalCost*2 + parseFloat(Flashing_upgrade_value);
    	var TotalCartons = Math.ceil(GrandTotalTubes/8);
    }
    
    function remove(table_id){
    	if(table_id=='1'){
    	alert("Can't delete the row");
    	return;
    	}
    	document.getElementById("Quote_req"+table_id).style.display='none';
    
    }
    
    
    </script>

  2. #2
    Join Date
    Jul 2011
    Posts
    3
    NumberOfTransformers is the variable in question

  3. #3
    Join Date
    Jul 2011
    Posts
    3
    duh if(variable1RoundUp <= variable2RoundUp)

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.15799 seconds
  • Memory Usage 2,884KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (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)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (3)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./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
  • ./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 (73):
  • 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
  • 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