Available Choices in Edit/New Form

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
armin o
Posts: 21
Joined: Sun Jan 17, 2016

26 Jan 2016

I want to set a dynamic default value of a single-value choice field (radio button type).

Q: How do i get the available choices as e.g. array of strings in order to determin the index of the choice value i want to set?


Thanks,
Armin

armin o
Posts: 21
Joined: Sun Jan 17, 2016

27 Jan 2016

I do this to get the array of (unselected) choices inside the new field: fd.field('SF_x0020_Lot_x0020_No').control()._el()[0]
.innerText.split('\n'); Two drawbacks: - Only works as long as nothing is actually selected. - Must be considered a hack
-Armin

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

27 Jan 2016

Hello,

Code: Select all

fd.field('choice').control()._el().find('td');
will get you all radio buttons in their correct order.

Code: Select all

fd.field('choice').control()._el().find('td').length
will give you how many buttons there are

Code: Select all

fd.field('choice').control()._el().find('td').eq(1)
will give you the second button

Code: Select all

fd.field('choice').control()._el().find('td').eq(1).find('label').text()
will give you the label of the second button

Code: Select all

fd.field('choice').control()._el().find('td').find('label')
will give you the labels of all buttons in their correct order


Code: Select all

fd.field('choice').control()._el().find('td').find('label').each(function( index ) {
console.log( index + ": " + $( this ).text() );
});
will print you all the labels with their indicies.

armin o
Posts: 21
Joined: Sun Jan 17, 2016

28 Jan 2016

Good morning Rostislav,

thank you for your detailed answer!

from http://spform.com/forms-designer- ... eld-values :

fd.field('ChoiceSingle').value('B');
does not work for me. Instead of 'B' i set the value like this:
fd.field('ChoiceSingle').value(ChoiceSingleChoices.indexOf('B'));
Maybe this is a documentation bug...
Best wishes,
Armin

armin o
Posts: 21
Joined: Sun Jan 17, 2016

28 Jan 2016

Sorry, i just flaged my last post while searching for a way to edit...Please ignore ;)

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests