Isaac
asked on
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:
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>
ASKER
Most of the code you saw was generated by SharePoint and was not completely my code but thanks for the suggestion.
ASKER
Can't figure out what the issue is
TesticeCreamTrucks.js
<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>
TesticeCreamTrucks.js
<script type="text/javascript">
$(document).ready(function() {
alert("HELLO");
})
function selectQry()
{
alert("HELLO WORLD");
}
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oh my Gosh!
Thank you so much. I can't believe I overlooked #1. That was the problem.
Thank you so much. I can't believe I overlooked #1. That was the problem.
You're welcome. Glad that I am able to help. Thanks for the points.
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.