Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If statements for Checkboxes

I wanted to know how to write if statements to see if one or another check box is checked or not.

I have two check boxes. I wanted it to check to see if checkbox 1 is checked and checkbox 2 is null then call this function, and if checkbox 2 is checked and checkbox 1 is null then call another function.

Pretty bad with IF statements and not sure how to convert the checkbox into a readable value.

like image 294
user1512593 Avatar asked Aug 07 '12 16:08

user1512593


2 Answers

I'm making an assumption that you mean not checked. I don't have a C# compiler handy but:

if (checkbox1.Checked && !checkbox2.Checked)
{

}
else if (!checkbox1.Checked && checkbox2.Checked)
{

}
like image 114
Science_Fiction Avatar answered Nov 15 '22 14:11

Science_Fiction


Your going to use the checkbox1.checked property in your if statement, this returns true or false depending on weather it is checked or not.

like image 38
DROP TABLE users Avatar answered Nov 15 '22 16:11

DROP TABLE users