macleodjb
03-08-2011, 11:57 PM
Hi guys,
I'm pretty new to jquery and I am trying to run a function every time my select box is changed. My code is below. What is happening is that whenever i have the function call in the text it kills the rest of my script. if i comment it out everything else works fine. Not sure what is wrong. I would like the run toggle_games_div() every time my select box is changed.
$(function(){
$('#country').change(function(){
$(toggle_games_div());
var Selected = document.getElementById('country').value
if(Selected > 0){
var data = {
action: 'get_country_games',
cat_id: $('#country').val()
};
jQuery.post(LPAjax.ajaxurl + "/mygames.php", data, function(response) {
alert('Got this from the server: ' + response);
});
};//EndIF
});//End of Change function
});
$(function toggle_games_div(){
var CValue = document.getElementById('country').value;
if(CValue > 0){
$('#table_wrapper_toggle').show();
} else {
$('#table_wrapper_toggle').hide();
}
});
I'm pretty new to jquery and I am trying to run a function every time my select box is changed. My code is below. What is happening is that whenever i have the function call in the text it kills the rest of my script. if i comment it out everything else works fine. Not sure what is wrong. I would like the run toggle_games_div() every time my select box is changed.
$(function(){
$('#country').change(function(){
$(toggle_games_div());
var Selected = document.getElementById('country').value
if(Selected > 0){
var data = {
action: 'get_country_games',
cat_id: $('#country').val()
};
jQuery.post(LPAjax.ajaxurl + "/mygames.php", data, function(response) {
alert('Got this from the server: ' + response);
});
};//EndIF
});//End of Change function
});
$(function toggle_games_div(){
var CValue = document.getElementById('country').value;
if(CValue > 0){
$('#table_wrapper_toggle').show();
} else {
$('#table_wrapper_toggle').hide();
}
});