Expected ';' Error

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>


Using IE Developer Tools, during debugging, I get this error:

Expected ‘;’ Error

This relates to either:

eval(ajax_CustContact[index].response);

OR

eval(ajax_CostCentreContact[index].response);

(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!

I have the same problem as you kool samule, I have a domain massmusclebuildingny.com but I cannot design it myself, I wonder why this happen, I already have a design last month about st. luis carpet cleaners and it runs swiftly.

So the problem is going to be in the code loaded into the response field and isn’t in the script in your page at all.

Problem solved:

I simplified the functions, using only 1 ajax call, which then displays all content, depending on which option was selected.

Thanks for the help. . . .

Problem solved:

I simplified the functions, using only 1 ajax call, which then displays all content, depending on which option was selected.

Thanks for the help. . . .

now i know

Hi,

There are two select menus to populate, and a div to be displayed, if ‘cust_id=1’.

I’m finding it difficult to display the response from the request.

Can you give me a couple of pointers, to see if I figure out where the error is coming from?

Or is there a better way of doing this all together?

Basically I have one select menu, the selected value is then passed to 3 ajax functions, which 1 returns a div and the other 2 populate select menus (?!)