1

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

2
  • 2
    Is it "Pick Pack" or "Pick Pack "? Commented Jan 28, 2013 at 11:57
  • 1
    parse selectedItems[2] before comparing Commented Jan 28, 2013 at 12:01

4 Answers 4

2

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]"; 
            }
Sign up to request clarification or add additional context in comments.

Comments

1

Try like this

if(selectedItems[2] === "Pick Pack"){
            var data = 'packing Method 1: '+selectedItems[2],
            alert(data);
}

Comments

1

I guess you are using triple === instead of double ==.

Comments

0

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]"; 
            }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.