mardi 16 juin 2015

how to write javascript to handle checkbox and send data to variable?

How to make this javascript work? if(checkbox2.click == true)

using MVC and bootstrap, there is a boolean true/false checkbox. but the SQL database must have a text only field.

the checkbox cannot be null, its true or false. In this code there must be a 3 state checkbox, true, false or not set/floating. But the script does not work at all, there is no alert, the breakpoint for the function never hits.

 <input type="checkbox"
           name="checkbox1"
           onclick="Applealert()" />Apple
    <br />
    <input type="checkbox"
           name="checkbox2"
           onclick="Orangealert()" />Orange     

   <script>
    function Applealert()
    {
    if(document.Form1.checkbox1.checked == true)
    {
    alert("You have clicked on Apple.");
    }
    }
    function Orangealert()
    {
     if(checkbox2.click == true)
    {
    alert("You have clicked on Orange.");
    }
    }

</script>




Aucun commentaire:

Enregistrer un commentaire