Get the index of a single choice field dropdown

rss

Posted by tjon.kim - Jul 6 ’15 at 12:04

Hi,

 

We have a two choice dropdown fields in a custom SharePoint list with the same number of choices in each field, one for the item, and one for the unit cost of the item.

 

We are trying to get the form to automatically pick the choice from the 2nd dropdown based on a selection in the first. For example, if the first choice is selected in the first dropdown, the first choice is selected in the 2nd dropdown, etc etc (1 to 1 relationship).

 

Is this possible? How can we get the index of the single choice dropdown and use that to set the value of the 2nd choice dropdown?

 

Thanks in advance.

  • rostislav
    rostislav
    Moderator
    Member for: 8 years 4 months 21 days
    #1 by rostislav Jul 6 ’15 at 09:47

    To get selected item's index:

    fd.field('dropdown1').control()._el().find('select')[0].selectedIndex
    

    To set a select's selected item by index:

    fd.field('dropdown2').control()._el().find('option').eq().prop('selected', true);
    

    If you want to set your dropdown box No. 2 to the value of the dropdown box No.1 when the No.1 changes selected item, you can use the change event, like this:

     fd.field('dropdown1').change(function(){
             var selectedIndex = fd.field('dropdown1').control()._el().find('select')[0].selectedIndex;
            fd.field('dropdown2').control()._el().find('option').eq(selectedIndex).prop('selected', true);
    });
    
  • tjon.kim
    Member
    Member for: 8 years 5 months 10 days
    #2 by tjon.kim Jul 12 ’15 at 10:41

    [#1]:  Thanks. That works!

  • seoexpert
    Member
    Member for: 1 year 2 days
    #3 by seoexpert Nov 20 ’22 at 04:30

    I want to make one of these 3D mobile games, and I will make them soon. I know an poruninstitutoparatodos.com who wants to get one of these boxes, and I will give one of these boxes with him soon.

  • seoexpert
    Member
    Member for: 1 year 2 days
    #4 by seoexpert Dec 20 ’22 at 01:35

    Super site! I am Loving it!! Will return once more, Im taking your food additionally, Thanks. cannabis bestellen in Deutschland

  • seoexpert
    Member
    Member for: 1 year 2 days
    #5 by seoexpert Jan 30 ’23 at 05:16

    Great survey. I'm sure you're getting a great response. Privacy Guides

  • seoexpert
    Member
    Member for: 1 year 2 days
    #6 by seoexpert Feb 1 ’23 at 06:34

    This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information... Elitevisa

  • seoexpert
    Member
    Member for: 1 year 2 days
    #7 by seoexpert Feb 1 ’23 at 11:00

    I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own Blog Engine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it. หวยลาว

  • seoexpert
    Member
    Member for: 1 year 2 days
    #8 by seoexpert Feb 2 ’23 at 02:01

    "I love the way you write and share your niche! Very interesting and different! Keep it coming! " internet providers Toronto

  • seoexpert
    Member
    Member for: 1 year 2 days
    #9 by seoexpert Feb 4 ’23 at 12:26

    If it's not too much trouble share more like that. popravka i servis racunara

  • seoexpert
    Member
    Member for: 1 year 2 days
    #10 by seoexpert Feb 11 ’23 at 10:11

    It was surely a treat to visit this site as I learned a lot from here. I was very much impressed by www.signnow.com/ask/how-to-sign-a-pdf-that-has-already-been-signed-by-someone-else. It was an informative post.

Displaying 1 to 10 of 35 messages
Previous1234