I try to change the color of a button if the two checkboxes are checked. But I can't figure out how to do this. I understand that I need javascript, but have no experience at all with javascript. I copied some lines from internet but this doesnot change the color of the button. So if the checkboxes are checked there should be another style selected for the button.
this is my code sofar:
<!DOCTYPE html>
<html>
<head>
<style>
.button1 {
background-color: #FF0000;
border: 4px;
border-radius: 20px 20px 20px 20px;
border-color: red;
color: yellow;
padding: 15px 25px;
text-align: center;
font-size: 16px;
cursor: pointer;
}
.button1:hover {
background-color: green;
}
.button2 {
background-color: #FF00FF;
}
</style>
<script type="text/javascript">
function checkbox_checked {
if (input.getAttribute('type') == 'checkbox' && input.checked)
n++;
checkbox_checked.elements.boxes_checked.value = n;
if n = 2 button.className = "button2";
}
</script>
</head>
<body style="background-color:#E3CEF6;">
<button class="button1">General</button>
<!-- Insert a table in a div, so this can be hide -->
<div id="General">
<table style="width:50%;margin-left:50px;">
<colgroup>
<col span="3" style="background-color:#E3CEF6;">
<col style="background-color:yellow">
</colgroup>
<tr>
<td><label class="container"> <input type="checkbox" name="cb_General_1"> <span class="checkmark"></span> </label> </td>
<td>Protocol name(s) : </td>
<td><input type="text" name="Protocol name(s)" size="35"> </td>
</tr>
<tr>
<td><label class="container"> <input type="checkbox" name="cb_General_2"> <span class="checkmark"></span> </label></td>
<td>Order name(s):</td>
<td><input type="text" name="Order name(s)" size="35"></td>
</tr>
</table>
</div>
</body>
</html>