locked
get picklist value messed up by case RRS feed

  • Question

  • Im retreiving the value of a picklist from the label.  the case of the lable im comparing is messing it up.

    is there a way to get the value/label of a picklist without the case of the label messing it up?
    Monday, February 1, 2010 5:50 PM

Answers

  • it so a monday -- just made the label and the string im comparing both lower case and it got it

    • Marked as answer by T Bonz Monday, February 1, 2010 6:03 PM
    Monday, February 1, 2010 6:03 PM

All replies

  • by case u mean upper/lower case?
    The value is the integer, so case has no meaning here. for name(label),
    you can convert it to lower() or upper() case using the following

    To convert a string to lower case in JavaScript we use the following steps:

    var sometext=”This is some text.”;
    var casechanged=sometext.toLowerCase();

    Now the variable casechanged contains “this is some text.”. For upper case in JavaScript:

    var sometext=”This is some text.”;
    var casechanged=sometext.toUpperCase();

    Monday, February 1, 2010 5:53 PM
  • Im retreiving the interger value from the label value

    if my string value is "Test" with value = 1 and i send over "test" it doesnt retreive the value of 1 

    Monday, February 1, 2010 5:56 PM
  • it so a monday -- just made the label and the string im comparing both lower case and it got it

    • Marked as answer by T Bonz Monday, February 1, 2010 6:03 PM
    Monday, February 1, 2010 6:03 PM
  • i am not sure, if i understood you properly, you have a problem in getting the value of the picklist? am i right? correct me if i am wrong.

    you can reterive it from the Picklist Options array.

    The following code example shows how to use a field of type Picklist. Note that when you add an option to a Picklist, the option must already exist in the set of possible options.

    var oField = crmForm.all.SOME_PICKLIST_FIELD_ID;
    
    // Capture the fourth option
    var oOption = oField.Options[4];
    
    // Show how many options are available
    alert("Original length :"+ oField.Options.length);
    
    // Set the field to the first option by value
    oField.DataValue = 1;
    
    // Show the text for the first option
    alert(oField.SelectedText);
    
    // Remove the fourth option
    oField.DeleteOption(4);
    
    // show the new length
    alert("New length :"+ oField.Options.length);
    
    // Restore the fourth option
    oField.AddOption(oOption.Text, oOption.DataValue);
    
    // Show the restored length
    alert("Restored length :"+ oField.Options.length);
    Monday, February 1, 2010 6:04 PM