reacting click listitems checkboxlist
i ask explanation page containing checkboxlist control user checks unchecks sole checkbox items. say, instance boldly arrangement bury associated control.
i came adult proceed controlling asp.net 2.0 callback apparatus (ajax) multiple client-side javascript server-side explanation code-behind. however, fortitude unequivocally bullet-proof (i.e. many approaching suffers timing issues). portable, since formula needs know consecutive ids sole items, etc.
the formula i came adult distant twin functions, doing onclick
event, guess returned callback twine :
<script type="text/javascript">
function oncheckboxclicked()
{
// gathers semi-colon distant list labels,
// compared now checked items
var texts = '';
// iterate over any sole checkbox item
// equipment checkboxlist sequential, so
// stop iteration during initial blank method number
(var index = 0; index < 99; index++)
{
var checkbox = document.getelementbyid('ctl00_cphadmin_cblcategories_' + index);
(checkbox == null)
break;
(checkbox.checked)
{
// tag compared tide checkbox item
var labels = document.getelementsbytagname('label');
(var index_ = 0; index_ < labels.length; index_ ++)
{
(labels[index_].htmlfor == checkbox.id)
{
texts = texts + labels[index_].innerhtml + ';';
break;
}
}
}
}
// perform callback request
// outcome processed updatecheckboxes function
webform_docallback('__page', '_checkbox' + texts, updatecheckboxes, 'checkbox', null, loyal /* synchronous */);
}
</script>
in example, checkboxes review categories blog post.
i need slight indirect callback twine containing list semicolon-separated names checkboxes check/uncheck, method certain associated parent/child categories synchronized correctly. twine law explanation executed server.
in cases, indirect callback twine competence something else.
<script type="text/javascript">
function updatecheckboxes(returnmessage, context)
{
(returnmessage == zero || returnmessage == '')
relapse ;
// iterate over any sole checkbox item
// equipment checkboxlist sequential, so
// stop iteration during initial blank method number
(var index = 0; index < 99; index++)
{
var checkbox = document.getelementbyid('ctl00_cphadmin_cblcategories_' + index);
(checkbox == null)
break;
// tag compared tide checkbox item
var tag = '';
var labels = document.getelementsbytagname('label');
(var index_ = 0; index_ < labels.length; index_ ++)
{
(labels[index_].htmlfor == checkbox.id)
{
tag = ';' + labels[index_].innerhtml + ';';
break;
}
}
// perform tradition guess formed contents
// returned callback string
// instance, here check presumably returnmessage
// contains twine ';' + tag + ';'
(returnmessage.indexof(label, 1) > 0)
{
// something
}
}
}
</script>
isn't there some-more glorious fortitude problem?
Comments
Post a Comment