I am having a problem, I am trying to make a link for a acsx file. Basically checkboxes get dynamically generated through pulling information out of a sharepoint 开发者_运维技巧list. These are HTML boxes. Ive tried using the runat=server on the boxes, ive tried using javascript to select the by creating a form that just contains the checkboxes but neither of those will select any checkboxes. Anyone have any idea on how I can select all the checkboxes on a page.
Thanks
Without really understanding, what you need to do, this JavaScript code will select all checkboxes within a container with the id boxes
(i.e. <div id="boxes">...</div>
):
var checkboxes = document.getElementById( 'boxes' ).getElementsByTagName( 'input' );
for ( var i = 0; i < checkboxes.length; i++ )
{
if ( checkboxes[i].type == 'checkbox' )
{
checkboxes[i].chcked = true;
}
}
(This is a solution without jquery & other frameworks, but of course if you are already using one, just use their built-in method for doing this)
something like this should do the trick:
$("input[type=checkbox]:not(:checked)").attr('checked','checked');
You could use jQuery to select all checkboxes in a page and set them that way.
精彩评论