Home › Forums › Classic DFFS › Get values on DispForm
- This topic has 3 replies, 3 voices, and was last updated 8 years, 8 months ago by Kelly Meegan.
-
AuthorPosts
-
-
April 25, 2016 at 16:45 #11244
I wanted to do some custom layout on a form (mostly checkboxes that get assigned different values based on whether they are checked or not) so I used some HTML and jquery to place the checkboxes and assign their values to their corresponding sharepoint columns. Then on the editform I use jquery to pull the value from the sharepoint column and check the checkbox if the sharepoint column value does not equal 0. This works great on the editform, however the it does not work on the dispform. I went ahead and added an alert to the code and noticed that the same alert code shows the correct value in the editform, but returns as ‘undefined’ in the dispform. I also added the fields to the tab on the dispform and they returned the proper values.
Code being used:
alert($(“input[title=’RefArch’]”).val());
alert($(“input[title=’NewTech’]”).val());First screenshot shows the working editform, second shows the dispform which does not recognize the value assigned to the sharepoint columns.
Thanks.
Attachments:
-
April 26, 2016 at 10:54 #11262
I don’t think they will be INPUT tags on the display form. You should refer to them by their ID’s instead.
-
April 26, 2016 at 21:59 #11280
Hi,
As Julian mentions above, you will not find any INPUT tags in DispForm. What you have here is the Yes / No values (depending on which language your SharePoint uses), or if you use DFFS the unicode representation of a checked / unchecked checkbox.You can use something like this to read the current value form the form:
var fieldValue = getFieldValue("YourBooleanFieldName), newVal = ""; if(fieldValue === "No"){ newVal = "NO - add your text or HTML code here"; }else if(fieldValue === "Yes"){ newVal = "YES - add your text or HTML code here"; } $("#dffs_YourBooleanFieldName").find("td.ms-formbody").html(newVal);
Hope this gets you a bit further.
Alexander
-
April 27, 2016 at 15:48 #11291
Thanks guys,
got it working as expected with:
if(getFieldValue("RefArch") != "0") { $('#refarch').prop('checked', true);}
-
-
AuthorPosts
- You must be logged in to reply to this topic.