Hello friends got a simple question again(im a noobi i know)

so got i got a checkbox in html i want to know how to manipulate checkboxes how i know if its checked...

blehh i explain in the code

<!DOCTYPE html>
<html>


<head><script type="text/javascript">

function myFunction() {
if (// checkbox is checked<<< this is my question how i write this ) {
//do this
                                                                     }

                      }



</script>
</head>



<body>

<input id="box1" type="checkbox" name="box1"/>                          //check box..
<input id="button" type="button" onclick="myFunction();" />     // boton , so ..say i want to alert Hello only if it checked
                                                              // how i do that? 


</body>

</html>

thx u guys rock!

Try this

    if(document.getElementById('box1').checked == true){
        alert('checked')
    }
    else{
        alert('not checked')
    }

thannk you <3

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.