How to access "child" values from "Parent" SharePoint fields
I can't seem to figure out how to dynamically access the child values for SharePoint fields that have multiple values.
For example:
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?
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?
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: viewtopic.php?f=4&t=44 but it did not work.
I tried this solution: viewtopic.php?f=4&t=154 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!
For example:
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?
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?
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: viewtopic.php?f=4&t=44 but it did not work.
I tried this solution: viewtopic.php?f=4&t=154 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
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi,
You can find how to get/set different types of fields in the following post:
http://spform.com/forms-designer- ... eld-values
You can find how to get/set different types of fields in the following post:
http://spform.com/forms-designer- ... eld-values
Thank you for the prompt reply. The http://spform.com/forms-designer- ... eld-values 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.
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.
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
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
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
You can retrieve an array of the selected indices following way:
Next, you can check whether a particular option is selected:
Code: Select all
fd.field('MultiChoice').value()
Code: Select all
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!');
}
-
- Information
-
Who is online
Users browsing this forum: No registered users and 6 guests