0

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!

Edited by centenond

2
Contributors
2
Replies
13
Views
3 Years
Discussion Span
Last Post by centenond
Featured Replies
  • Try this if(document.getElementById('box1').checked == true){ alert('checked') } else{ alert('not checked') } Read More

1

Try this

    if(document.getElementById('box1').checked == true){
        alert('checked')
    }
    else{
        alert('not checked')
    }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.