Old 6
Old 6
html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Course Curriculum Builder</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: #f5f5f5;
}
#courseBuilder {
max-width: 800px;
margin: auto;
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.section {
margin-top: 20px;
padding: 10px;
background-color: #f9f9f9;
border-radius: 5px;
}
label {
display: block;
margin-bottom: 5px;
}
input, select, textarea {
width: 100%;
padding: 8px;
margin-bottom: 10px;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
background-color: #4caf50;
color: white;
padding: 10px;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
.edit-delete button {
background-color: #f44336;
margin-right: 10px;
}
.edit-delete button:hover {
background-color: #d32f2f;
}
.edit-input {
display: none;
}
@media only screen and (max-width: 600px) {
#courseBuilder {
width: 90%;
}
}
</style>
</head>
<body>
<div id="courseBuilder">
<h2 style="text-align: center;">Course Curriculum Builder</h2>
<div class="edit-delete">
<button type="button" onclick="addSection()">Add Section</button>
<button type="button" onclick="removeSection(1)">Remove
Section</button>
</div>
</div>
</div>
<script>
let sectionCounter = 1;
function addSection() {
sectionCounter++;
const sectionContainer = document.getElementById('courseBuilder');
const sectionDiv = document.createElement('div');
sectionDiv.className = 'section';
sectionDiv.id = `section${sectionCounter}`;
sectionDiv.innerHTML = `
<label for="sectionName${sectionCounter}">Section Name:</label>
<input type="text" id="sectionName${sectionCounter}"
name="sectionName[]">
<div class="edit-delete">
<button type="button" onclick="addSection()">Add Section</button>
<button type="button" onclick="removeSection($
{sectionCounter})">Remove Section</button>
</div>
`;
sectionContainer.appendChild(sectionDiv);
setupContentOptionEvents(sectionDiv);
}
function removeSection(sectionId) {
const sectionDiv = document.getElementById(`section${sectionId}`);
sectionDiv.remove();
}
function setupContentOptionEvents(sectionDiv) {
const contentOptionSelect =
sectionDiv.querySelector(`select[name="contentOption[]"]`);
const specificContentDiv = sectionDiv.querySelector('.specific-content');
contentOptionSelect.addEventListener('change', function() {
const selectedOption = contentOptionSelect.value;
specificContentDiv.innerHTML = ''; // Clear previous content
</body>
</html>