I have put together this section of code which does what it's supposed to do. The only problem is when I deselect the first checkbox the shopping cart box remains. I want the top box to be the master, so if that's not selected the program will display nothing. Here's what I have so far:
function shoppingcartFunction() {
// Get the checkbox
var checkBox = document.getElementById("myCheck");
// Get the output text
var text = document.getElementById("text");
// If the checkbox is checked, display the output text
if (checkBox.checked == true) {
text.style.display = "block";
} else {
text.style.display = "none";
}
}
function shoppingcart1Function() {
// Get the checkbox
var checkBox = document.getElementById("shopping_cart");
// Get the output text
var text = document.getElementById("text1");
// If the checkbox is checked, display the output text
if (checkBox.checked == true) {
text.style.display = "block";
} else {
text.style.display = "none";
}
}
Checkbox: <input type="checkbox" id="myCheck" onclick="shoppingcartFunction()">
<p id="text" style="display:none"><label for="sender_name">Shopping Cart:
<input type="checkbox" id="shopping_cart" onclick="shoppingcart1Function()"> <br /><br /></p>
<p id="text1" style="display:none"><label for="sender_name">Shopping Cart</label><br />
<input type="text" id="shopping_car" pattern="[A-Za-z]{ ,30}" maxlength="30" title="Max 30 characters" name="shopping_car" size="30" required>*
<br /><br /></p>