locked
How Do I disable certain values in drop down box RRS feed

  • Question

  •  

    I want the user only to be able to choose certain values

     

    Friday, May 23, 2008 5:50 PM

Answers

  • DevintheDude,

     

    Matt is right in that the only way to limit what users pick from a dropdown/picklist field is to remove/delete the option through Jscript.  Here's an example from the SDK that should help you.  The article is titled "Picklist", if you search the SDK for "picklist option" you should get everything you need.

     

    Here's the code:

     

    The following code example shows how to use a field of type Picklist. Note that when adding 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);

     

    Good luck,

     

    Fronk

    Friday, May 23, 2008 9:47 PM

All replies

  • You can add/remove items to the picklist via javascript code and modifying the "Options" property.

     

    Friday, May 23, 2008 7:25 PM
    Moderator
  • DevintheDude,

     

    Matt is right in that the only way to limit what users pick from a dropdown/picklist field is to remove/delete the option through Jscript.  Here's an example from the SDK that should help you.  The article is titled "Picklist", if you search the SDK for "picklist option" you should get everything you need.

     

    Here's the code:

     

    The following code example shows how to use a field of type Picklist. Note that when adding 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);

     

    Good luck,

     

    Fronk

    Friday, May 23, 2008 9:47 PM