[Multiselect] Loop through all the elements of the node

Hi!
I want to disable “multiselect” when end_date <= current time. But i have some troubles:

  • I can’t set value again by this code: " node.firstChild.value=value||""
  • how can I loop through all the elements of the node
    Now, I just know “node.firstChild” or “node.lastChild”.

scheduler.form_blocks.multiselect.set_value=function(node,value,ev){ var endDate = new Date(ev.end_date); var timeNow = new Date(); node.firstChild.value=value||""; if(endDate <= timeNow) { var style = ev.some_property ? "":"#ccc"; node.firstChild.disabled = 'disabled'; node.firstChild.style.background = '#fff'; } }
How can I do that? thanks…

Hello,
instead of modifying source code of multiselect control, i’d suggest to disable checkboxes from the onBeforeLightbox event handler. Code might be following:

[code]scheduler.attachEvent(“onBeforeLightbox”, function(id){
var past = (scheduler.getEvent(id).end_date - new Date()) >= 0;

var multi = scheduler.formSection("userselect").node,
	chboxes = multi.getElementsByTagName("input");

for(var i= 0, len = chboxes.length; i < len; i++){
	if(past)
		chboxes[i].setAttribute("disabled", true);
	else
		chboxes[i].removeAttribute("disabled");
}

return true;

});[/code]
please note that code uses control named “userselect”, you’ll need to replace it with an actual name of your control

Thanks for your help!
When I show [console.log] like this below:

[code]scheduler.attachEvent(“onBeforeLightbox”, function(id){
var past = (new Date(scheduler.getEvent(id).end_date) - new Date()) <= 0;

    var multi = scheduler.formSection("menu_id").node,
      chboxes = multi.getElementsByTagName("input");
    
    for(var i= 0, len = chboxes.length; i < len; i++){
        if(past) {
            chboxes[i].setAttribute("disabled", true);
        } else {
            chboxes[i].removeAttribute("disabled");
        }
        console.log(chboxes[i]);
    }
    return true;
});[/code]

It’s show:

<input type="checkbox" value="3" disabled="true"> <input type="checkbox" value="7" disabled="true"> <input type="checkbox" value="2" disabled="true"> <input type="checkbox" value="4" disabled="true"> <input type="checkbox" value="5" disabled="true"> <input type="checkbox" value="1" disabled="true"> <input type="checkbox" value="6" disabled="true">
But when the lightbox was shown. Multiple select has not been disabled.
I don’t know why… :cry:

Ah, I have solved the problem. I used to use onLightbox instead of onBeforeLightBox.
Thanks for your help…!