Expected ';' Error

Discussion in 'JavaScript' started by koolsamule, Aug 18, 2010.

  1. #1
    Hi Chaps,

    I'm still having problems with a Javascript 'Lookup' function.

    Basically, I have a select menu 'Customer' which triggers a 3 JS functions, to populate 2 extra select menus.
    
    <script type="text/javascript" language="javascript">
               $(document).ready(function(){
                    $('#customer').change(function() {
                        var option=$(this).val();
    					getCustContact(this);
    					getCostCentreContact(this);
                        $.get('getCostCentre.php',{select:option},function(data){
                            $('#result').html(data).hide().fadeIn(1000);
                        });
                    });
                });
    </script>
    <script type="text/javascript" language="javascript">
    var ajax_CustContact=new Array();
    function getCustContact(sel)
    {
    	var Customer=sel.options[sel.selectedIndex].value;
    	document.getElementById('custcontact').options.length = 0;
    	if(Customer.length>0){
    		var index=ajax_CustContact.length;
    		ajax_CustContact[index]=new sack();
    		ajax_CustContact[index].requestFile='getCustomerContact.php?custid='+Customer;
    		ajax_CustContact[index].onCompletion=function(){createCustContact(index)};
    		ajax_CustContact[index].runAJAX();
    	}
    }
    function createCustContact(index)
    {
    	var obj=document.getElementById('custcontact');
    	eval(ajax_CustContact[index].response);
    }
    </script>
    <script type="text/javascript" language="javascript">
    var ajax_CostCentreContact=new Array();
    function getCostCentreContact(sel)
    {
    	var Customer=sel.options[sel.selectedIndex].value;
    	document.getElementById('costcentrecontact').options.length = 0;
    	if(Customer.length>0){
    		var index=ajax_CostCentreContact.length;
    		ajax_CostCentreContact[index]=new sack();
    		ajax_CostCentreContact[index].requestFile='getCostCentreContact.php?custid='+Customer;
    		ajax_CostCentreContact[index].onCompletion=function(){createCostCentreContact(index)};
    		ajax_CostCentreContact[index].runAJAX();
    	}
    }
    function createCostCentreContact(index)
    {
    	var obj=document.getElementById('costcentrecontact');
    	eval(ajax_CostCentreContact[index].response);
    }
    </script>
    
    
    <select id="customer" name="FK_cust_id">
                <option value="">Select Customer</option>
                <option value="1">Customer A</option>
                <option value="2">Customer B</option>
    </select>
    
    <select id="custcontact" name="FK_contact_id">
                <option value="">--Select Customer First--</option>
    </select>
    
    <select id="costcentrecontact" name="FK_cost_centre_contact_id">
                <option value="">--Select Customer First--</option>
    </select>
    
    
    Code (markup):
    Using IE Developer Tools, during debugging, I get this error:
    This relates to either:
    eval(ajax_CustContact[index].response);
    Code (markup):
    OR
    eval(ajax_CostCentreContact[index].response);
    Code (markup):
    (it's a bit random, as sometimes it works, sometimes it doesn't)

    I have tried changing the 'custid' to 'custname' to check whether it was an integer causing the problem, but had the same problem.

    If anyone can tell me where I am going wrong, I'd gladly give out a bit hi-5!
     
    koolsamule, Aug 18, 2010 IP