Posts tonen met het label Checked. Alle posts tonen
Posts tonen met het label Checked. Alle posts tonen

dinsdag 26 november 2013

Set a check or more checkboxes of a choice field selected.


A nice new function is created today for my colleague
If you want to check a checkbox of a checkbox field or a multi choice field, 
you can use the next function. 
You can call it by not knowing the GUID of the checkbox you want to select. But you can call it with 
the Display Name (Title) of your field. 
If it only one checkbox, you call it like this :
SetChoiceFieldValue ("YOUR TITLE", 1, true);
 
If you have a choice field with more options, you can select specific entries 
by setting the index to the checkbox you want to select. 
You can use the same function also to uncheck the field. You only have to set the last param to false. 

It's a nice jquery function that makes your scripting more flexible. 


 
function SetChoiceFieldValue(titel, index, b_checked)
{
        var TD = $('nobr:contains("'+ titel + '")').closest("td").next("td").find('input');
        if (index <= TD.length + 1)
        {
                TD[index-1].checked = b_checked;
        }
}

zaterdag 12 oktober 2013

Check if a Multi Selectable Sharepoint Choice Field value is Checked.


I'm starting to write my own sharepoint helperclass with functions 
that can be called without knowing the ID's of the Sharepoint Fields, 
but by using the field Display Names. 

This function is to know if a certain value of a multi selectable 
choice field is checked or not.


// call the function
// CheckChoiceFieldValue ("DISPLAYNAME", 1) check of first value is checked
// CheckChoiceFieldValue ("DISPLAYNAME", 2) check of second value is checked
  
function CheckChoiceFieldValue(titel, index)
{
 var TD = $('nobr:contains("'+ titel + '")').closest("td").next("td").find('input');
    var bTD = false;
    if (index <= TD.length + 1)
    {
  return TD[index-1].checked;
 }
    return false;
}