onchange event error

I get the following error:
SCRIPT5007: The value of the property 'selectQry' is null or undefined, not a Function object
Here's the site: http://isaac.issharepoint.com/demo/pages/iceCreamTruckTracker.aspx

Here's the code if you can't get to the site:

<script>

		<select id="qry" onchange="selectQry()">
		   <option value="State">State</option>
		   <option value="Town Name">Town Name</option>
		   <option value="County Name">County Name</option>
		</select>

$(document).ready(function() { 

//onchange event will trigger getArrayCount() method


	function selectQry(list) {
	var qryVal = list.options[list.selectedIndex].value;
	console.log("Selected selection: "+qryVal);
	
}
//Create name space so their will be no collisions if application grows
	var iceCreamApp = {};
	iceCreamApp.Truck = new Array();
	
	//Load data from list into array right away
	(function() {
		//IIFE() Imediately Invoked Function
		var url = "http://isaac.issharepoint.com/demo/_vti_bin/listdata.svc/IceCreamTrucks?$select=State,TownName,CountyName,IceCreamTrucks";
		$.ajax({
			url:url,
			type:"GET",
			dataType:"json",
			headers: {
                "accept": "application/json;odata=verbose",
                "X-RequestDigest": $("#__REQUESTDIGEST").val()
            },
			success: function(data) {
			//console.log(data.d);
				success(data);
			},
			error: function(data) {
				//failure(data);
				//console.log("ERROR");
			}
		})
			
		function success(data)
		{
			var iceCreamTrucks = data.d.results;
				for(var i = 0; i<iceCreamTrucks.length; i++)
				{
					iceCreamApp.Truck.push(new ICIItem({State:iceCreamTrucks[i].State,
					                           TownName:iceCreamTrucks[i].TownName,
											   CountyName:iceCreamTrucks[i].CountyName,
											   TruckCnt:iceCreamTrucks[i].IceCreamTrucks}));
				}
		}
	}());	
})


function ICIItem(params)
{
	this.TruckCnt = params.TruckCnt;
	if (this.TruckCnt > 5)
	{
		//do something
	}	
	this.State = params.State;
	this.TownName = params.TownName;
	this.CountyName = params.CountyName;
};
ICIItem.prototype.getArrayCount = function(cntType)
{
//Build array number of trucks based on town, state or county. Will be passed in as "cntType"

//pass array to function that will use jqplot
}
		$.each(ticketArray, function (index, value) {			
        		myData.push([ticketArray[index].TicketType, ticketArray[index].Count]);	
 		});
		
	
</script>

Open in new window

LVL 5
IsaacSharePoint Client Side DeveloperAsked:
Who is Participating?
 
Brian TaoSenior Business Solutions ConsultantCommented:
1. don't include <script type="text/javascript"> and </script> in a js file (TesticeCreamTrucks.js).
2. documentGetElementsByName is not defined: there's documentGetElementsByName somewhere in your code.  It should be document.getElementsByName (note that you missed a dot (.) and the (G)et should be lower case g.

Note. since I'm unauthorized and banned from entering the site, there's some other bugs that I think may come from the unauthorization so I'm skipping them now.

Let me know if you still have problem after you fix these 2 things.
0
 
Brian TaoSenior Business Solutions ConsultantCommented:
The cause of the error is that you have 2 sets of <html><head></head><body></body></html> so the .js file linked in the 2nd set is not recognized by your browser.

BTW, reading your source from "View Source" is really painful.  Have you ever considered cleaning it up?  By cleaning it up I guess you'd have already found such issue.
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
Most of the code you saw was generated by SharePoint and was not completely my code but thanks for the suggestion.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
IsaacSharePoint Client Side DeveloperAuthor Commented:
Can't figure out what the issue is
<script type="text/javascript" src="http://isaac.issharepoint.com/demo/JavaScriptCode/TesticeCreamTrucks.js"></script>

<table>
	<tr>
		<td colspan="2"></td>
	</tr>
	<tr>
		<td colspan="2">
		<select id="qry" onchange="selectQry()">
		   <option value="State">State
		   <option value="Town Name">Town Name
		   <option value="County Name">County Name
		</select>
		</td>
	</tr>	
	<tr>
		<td></td>
		<td></td>
	</tr>
</table>

Open in new window



TesticeCreamTrucks.js
<script type="text/javascript">
$(document).ready(function() { 
alert("HELLO");

	
})

function selectQry()
{
   alert("HELLO WORLD");
}
</script>

Open in new window

0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
Oh my Gosh!
Thank you so much.  I can't believe I overlooked #1.  That was the problem.
0
 
Brian TaoSenior Business Solutions ConsultantCommented:
You're welcome.  Glad that I am able to help.  Thanks for the points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.