I am working on a sharepoint server 2013. and inside my built-in create.aspx list form i added the following javascript code:-

var selectobject = document.getElementById("Approver_90afaad9-2b54-46fb-8ac1-7374e4efa11e_$DropDownChoice");

for (var i=selectobject.options.length-1; i>=0; i--)


now as shown in the code i am selecting a drop-down list based on its id, then i am removing its choices.

now i want to modify my javascript to use the SPUtility.js library to reference the columns using their internal names, rather than referencing them using their markup id. but i am not sure if SPUtility.js will support or provide the features to remove choices from my drop-down list as i am current doing inside my pure javascript code?

so if i replace this:-

var selectobject = document.getElementById("Approver_90afaad9-2b54-46fb-8ac1-7374e4efa11e_$DropDownChoice");

with SPUtility.js syntax:-

var selectobject = SPUtility.GetSPFieldByInternalName('Approver');

will i still be able to remove the choices??

  • Why don't you try the code? Commented May 30, 2017 at 12:47
  • You are halfway there, so indeed you could give it a shot of your own. Though, a pure JavaScript-solution (non-library dependent) can be implemented to get element by its content (e.g. divs[i].innerHTML.indexOf("Approver")).
    – moe
    Commented May 30, 2017 at 13:17
  • @moe i went with using SPUtility appraoch as it will provide the most standard way to select columns inside my create/edit forms. as i do not need to go through the markup which i do not own and which might change in the future if we update sharepoint. now i know that using SPUtility mean that i will add a dependency inside my sharepoint. but i will live with this drawback as it will allow me to say that i want to select a field inside my form which have ...
    – John John
    Commented May 30, 2017 at 13:41
  • ...for example the following internal name SPUtility.GetSPFieldByInternalName('Approver');.. but i am not sure if i will be able to add choices to the element which i select using SPUtility()?
    – John John
    Commented May 30, 2017 at 13:41
  • @harshalgite which code i should test ?
    – John John
    Commented May 30, 2017 at 13:41

1 Answer 1


Try accessing the DropDown property of the selectedObject. Haven't tried SPUtility library but looks like (after examining the code) that the HTML object is available in "DropDown" for choice fields.

Have a look at the code example here: https://github.com/kitmenke/sputility/blob/master/examples/dropdownchange.html

$(countryField.Dropdown) is used to get the dropdown control.

Once you access the html control you can do anything with it. If you prefer with jquery like (to remove an option with value 'TEST'):

  • I like to disable them in some cases. $(countryField.Dropdown).find("option[value='TEST']").attr('disabled','disabled');
    – AtariPixel
    Commented Jan 27, 2019 at 13:29

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.