Tag Archive for checked

Require a checkbox to be checked:

<asp:CustomValidator runat="server" ID="rfvMember" OnServerValidate="cbMember_Validate" ValidateEmptyText="true" ErrorMessage="Member coverage is required." Display="None"></asp:CustomValidator>


protected void cbMember_Validate(object sender, ServerValidateEventArgs e)
	{
		e.IsValid = cbMember.Checked;
	}

source

pear quickform multiple checkbox checked

	$checkobj = array();
foreach($Categories as $h => $ValueC){
$checkobj = HTML_QuickForm::createElement('checkbox', $h ,null ,utf8_encode($ValueC['category']));
if(count($CategoryGroups) > 0){

foreach ($CategoryGroups as $KeyC => $ValC) {
if($ValueC['id'] == $KeyC){
echo "<pre>";
print_r($KeyC);
echo "</pre>";
$checkobj->setChecked(true);
}
}
}
$checkboxen[] = $checkobj;
}
$form->addGroup($checkboxen, 'categ', $_lang['daten']['category'], '', true);

source

Check Parent Node When Last Child is Checked

Private Sub TreeView1_AfterCheck(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterCheck

Dim blnUncheck As Boolean = False

'Check to see if a parent node exists.
If Not e.Node.Parent Is Nothing Then

'Loop through the child nodes.
For Each child As TreeNode In e.Node.Parent.Nodes

'Check to see if the current node is unchecked.
If child.Checked = False Then

'Set the variable.
blnUncheck = True
End If
Next

'Check the variable.
If blnUncheck = False Then

'Check the parent node.
e.Node.Parent.Checked = True
Else

'Uncheck the parent node.
e.Node.Parent.Checked = False
End If

End If

End Sub

source

checkbox with associated values checked

<% Company.find(:all).each do |c| %>
<input type="checkbox" name="technology[company_ids][]" value="<%= c.id %>"
<% if @technology.companies.include?(c) -%> checked="checked" <% end -%> />
<%= c.name %></td>
<% end %>

source

Easy default options for methods in Ruby

def my_method(opts={})
{:arg_one => 'foo', :arg_two => 'two'}.merge(opts)
end

source