How to access "child" values from "Parent" SharePoint fields

rss

Posted by Jdubs - Dec 19 ’14 at 11:12

I can't seem to figure out how to dynamically access the child values for SharePoint fields that have multiple values.

 

For example:

  1. Checkbox field: If I have 2 (or more) checkbox values for ONE "Parent" Checkbox SharePoint field, how do I access the values of the various "child" checkbox values so that I can make the form perform certain actions depending on which checkbox (or more) are checked?
  2. Date AND Time field: The SharePoint Date and Time field populates with THREE values:  Date, Hour, and Minute.  How do I access the "Hour" field and the "Minute" field so that I can pre-populate those boxes with the current hour and minute?
  3. Radio button: If I have a Radio button SharePoint field, how do I access the multiple choices a user can make on the single Radio box?

I tried this solution: http://forum.spform.com/forms-designer/multiple-choice-30/ but it did not work.

I tried this solution: http://forum.spform.com/forms-designer/multi-selection-choice-20115/ but it only works by checking the value of ONE "child" value.  I need to dynamically be able to access any (or all) of the child values.

 

In HTML this is easy:  document.getElementById("childValue") allows you to access and sub element directly.

 

Thanks!

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 2 months 19 days
    #1 by Dmitry Kozlov Dec 19 ’14 at 11:15

    Hi,

    You can find how to get/set different types of fields in the following post:

    http://formsdesigner.blogspot.com/2013/04/getting-and-setting-sharepoint-form.html

  • Jdubs
    Member
    Member for: 4 years 11 months 20 days
    #2 by Jdubs Dec 19 ’14 at 03:49

    Thank you for the prompt reply.  The http://formsdesigner.blogspot.com/2013/04/getting-and-setting-sharepoint-form.html was referenced in one of the links I provided.

     

    The problem is this:

    Choice Multiple Get
    var checkboxIndex = 2; //You are setting an absolute index value here; this code will not work if the user selects a value other than 2.
    fd.field('MultiChoice').control()._el()
      .find('input[type="checkbox"]').eq(checkboxIndex)//Again, this only checks if checkbox value is = 2.  What about 0, 1, 3, etc.?
      .is(':checked');

     

    The other problem:

    OnChange

    fd.field('MultiChoice').change(function(){
      alert('Field changed!');//This checks if the FIELD changes, but I still can not retrieve the value.
    });
    //When the field changes, I want to be able to change the form dynamically, depending on if they chose Choice 1, Choice 2, Choice 1 AND 2, etc.
  • Jdubs
    Member
    Member for: 4 years 11 months 20 days
    #3 by Jdubs Dec 19 ’14 at 03:53

    [#2]: Sorry, looks like my previous reply did not render properly.

    Here's what my comments said:

     

    Problem:

    //You are setting an absolute index value here; this code will not work if the user selects a value other than 2.
    //Again, this only checks if checkbox value is = 2.  What about 0, 1, 3, etc.?
    

     

    The other problem:

    //This checks if the FIELD changes, but I still can not retrieve the value.

    //When the field changes, I want to be able to change the form dynamically, depending on
  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 2 months 19 days
    #4 by Dmitry Kozlov Dec 22 ’14 at 08:23

    [#3]: You can retrieve an array of the selected indices following way:

    fd.field('MultiChoice').value()

    Next, you can check whether a particular option is selected:

    if ($.inArray(0, fd.field('MultiChoice').value())) {
      alert('The first option is selected!');
    }
    
    if ($.inArray(1, fd.field('MultiChoice').value())) {
      alert('The second option is selected!');
    }
    
  • Jdubs
    Member
    Member for: 4 years 11 months 20 days
    #5 by Jdubs Dec 26 ’14 at 03:52

    Thank you Dmitry!

Displaying 1 to 5 of 5 messages