1.11M Members

simple question

 
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!

 
1
 

Try this

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

thannk you <3

Question Answered as of 6 Months Ago by Mallika_P
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article