locked
Dropdown Remove Selected Item On Post Back RRS feed

  • Question

  • Hi,

    I have a Place Order Form and I have a drop down list that contains list of items binding from

    sharePoint list dynamically. Whenever I add item (for example item1) to place order and click add

    another item button,I need to remove (item1 ) from drop down list to avoid duplicate insert in the

    sharepoint list or maybe need to fill the drop down but without (item1) cause i already selected it.

    Please give me the solution.

    Thanks for the help in advance.

    Kumar.

    Saturday, December 6, 2014 2:06 AM

Answers

  • Hi,

    Per my understanding, there might be a Drop Down List and a button “add another item” in your NewForm.aspx of a list. You want to populate the Drop Down List with the unique values from the list dynamically when clicking the “add another item” button.

    There is a way that you can use JavaScript with Client Object Model to implement this asynchronous operation dynamically.

    With JavaScript Client Object Model, we can add/retrieved list items:

    http://msdn.microsoft.com/en-us/library/office/hh185006(v=office.14).aspx

    More information about JavaScript Client Object Model:

    How to: Create, Update, and Delete List Items Using JavaScript

    http://msdn.microsoft.com/en-us/library/office/hh185011(v=office.14).aspx

    When clicking the “add another item” button, we add an item to the list. After the item added to the list, try retrieving all the items from this list.

    Once we retrieved all the items in an array, we can filter the unique items and populate them into the Drop Down List.

    About how to get unique values from a list:

    http://jszen.com/best-way-to-get-unique-values-of-an-array-in-javascript.7.html

    Best regards,

    Patrick


    Patrick Liang
    TechNet Community Support

    • Marked as answer by Patrick_Liang Tuesday, December 23, 2014 2:56 AM
    Monday, December 8, 2014 2:49 AM