Reputation: 7953
i have a combo box from where i get values and i get the values also correct but when i compare them it is not getting compared and i don't get the results too.
if(selectedItems[2] === "Pick Pack"){
alert("packing Method 1: "+selectedItems[2]);
global.getElementById("CIMtrek_daily_contact_1").value="";
global.getElementById("CIMtrek_daily_contact_1").value="[email protected]";
}
when i printed selectedItems[2]
it gives me Pick Pack
but does not get in to the if condition and alert.
I tried to alert but the alert is not coming. Please help me to fix this
Best Regards
Upvotes: 1
Views: 95
Reputation: 2100
Try using
String.prototype.trim=function(){
return this.replace(/^\s+|\s+$/g, '');
};
and
if(selectedItems[2].trim() === "Pick Pack"){
alert("packing Method 1: "+selectedItems[2]);
global.getElementById("CIMtrek_daily_contact_1").value="";
global.getElementById("CIMtrek_daily_contact_1").value="[email protected]";
}
Upvotes: 2
Reputation: 7953
Thanks for the posting. Abhijeet Pawar
and Florian Margaine
comments gave me start to fix this issue
the following is the code helped to fix the issue;
if($.trim(selectedItems[2]) === $.trim("Pick Pack")){
global.getElementById("CIMtrek_daily_contact_1").value="";
global.getElementById("CIMtrek_daily_contact_1").value="[email protected]";
}
Upvotes: 0
Reputation: 28763
Try like this
if(selectedItems[2] === "Pick Pack"){
var data = 'packing Method 1: '+selectedItems[2],
alert(data);
}
Upvotes: 1