I'm trying to load some content via Ajax and fancybox, I have a problem establishing a validation before fetching the content. I'm trying to check if the array has some value first, and does not equal the default first dropdown option, then proceed.
My first element of the dropdown is the Select Object with a value Object, but for example if I select X, content will load, then if I select Object, the validation is not working, and content for the last selection is loading.
HTML
<select id="sat" onChange="get_bm(this.value)">
<option value="Object" selected="selected">Object Name</option>
<option value="X" selected="selected">X</option>
<option value="Y" selected="selected">Y</option>
</select>
<input name="Btn" class="toolsMenu channel fancybox.ajax" href="content.php" onclick="get_info()"/>
Javascript
function get_info(){
var Satquery = new Array(); //create Array with two dropdown selections
var bm = document.getElementById("bm").value; //Get Dropdown1 value
var sat = document.getElementById("sat").value; // Get Dropdown2 value
Satquery [0] = bm;
Satquery [1] = sat;
if (Satquery[1] !== 'Object' || Satquery[0] !== null ){ //Here some validation that its not empty and does not equal the default selection option
$(".channel").fancybox({
ajax : {
type : "POST",
data : "Sat="+Satquery
},
fitToView : true,
autoDimensions : true,
closeClick : false,
openEffect : 'none',
closeEffect : 'none'
});
}
Satquery =[]; /// Here Im trying to empty the array after each click because if I select again 'Select object' with value 'Object' the validation is not working and content for last selected item is being loaded..
}