Question

I have the following javascript snippet, which fails to load due to a missing ; before statement before thr declarion of url withing searchUserInfo.. I have double and triple checked this code

function submitUserInfo(username) {

    url = "edit_user.php?cmd=submitinfo&username="+username+"&firstname="+document.userForm.firstname.value+"&lastname="+document.userForm.lastname.value+"&flaggedauctions="+document.userForm.flaggedauctions.value+"&lastauction="+document.userForm.lastauction.value+"&street1="+document.userForm.street1.value+"&city1="+document.userForm.city1.value+"&postcode1="+document.userForm.postcode1.value+"&street2="+document.userForm.street2.value+"&city2="+document.userForm.city2.value+"&postcode2="+document.userForm.postcode2.value+"&phone="+document.userForm.phone.value+"&mobilephone="+document.userForm.mobilephone.value+"&fax="+document.userForm.fax.value+"&email="+document.userForm.email.value+"&website="+document.userForm.website.value+"&bank="+document.userForm.bank.value+"&banknumber="+document.userForm.banknumber.value+"&accountnumber="+document.userForm.accountnumber.value+"&comments="+document.userForm.comments.value;

    var xmlHttp=GetXmlHttpObject(); //you have this defined elsewhere

    //if(xmlHttp.responseText == 'true') {

        xmlHttp.open("GET",url,true);

        xmlHttp.send(null);

        updateByUser(username);

    //}

}

function searchUserInfo() {

    url = "get_results.php?cmd=SearchUserData&searchstring="+document.searchForm.search.value"&subcat="+subcat;

    var xmlHttp=GetXmlHttpObject(); //you have this defined elsewhere

    //if(xmlHttp.responseText == 'true') {

        xmlHttp.open("GET",url,true);

        xmlHttp.send(null);

        update('Layer3', url);

    //}

}

I have used jslint, and can not see what, if anything has changed. There are no errors. I am using firebug, but it does not aid me.

Was it helpful?

Solution

You forgot a + operator. This:

url = "get_results.php?cmd=SearchUserData&searchstring="+document.searchForm.search.value"&subcat="+subcat;

Should be:

url = "get_results.php?cmd=SearchUserData&searchstring="+document.searchForm.search.value+"&subcat="+subcat;

OTHER TIPS

You are missing a + here

value"&subcat="+subcat

searchUserInfo, first line, you need to add a "+"

...document.searchForm.search.value + "&subcat="...

Double, Triple, Quadruple checks are good but not enough. Comment out lines of code at a time to pinpoint the line with the error.

and remember this "The computer is never wrong" and get used to it.

e.g.

first test:

/*
function blah(do){
   line 1
   line 2
   line 3
}
*/

then:

function blah(do){
/*
   line 1
   line 2
   line 3
*/
}

then:

function blah(do){

   line 1
   /*
   line 2
   line 3
   */

}

until the error shows itself

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top