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;

Geen opmerkingen:

Een reactie posten