$(document).ready(function() { // Event handler for Add Stream button $('#addStreamBtn').click(function() { event.preventDefault(); // Prevent default form submission var selectedStream = $('#textStream').val(); if (selectedStream) { // Send selected stream value to the server via AJAX $.ajax({ type: "POST", url: "topicsinputactions?addstream=1;", // Update the URL with the actual server-side script URL data: { stream: selectedStream }, success: function(response) { // Check if the response is successful if (response.success) { // Update the session array on the client-side streams.push(selectedStream); updateTable(); // Update the table } else { alert(response.error); } }, error: function(xhr, status, error) { alert("An error occurred: " + error); } }); } else { alert('Please select a stream first.'); } }); }); // Function to update the table with data from the session variable function updateTable() { var tableBody = $('#streamTable tbody'); tableBody.empty(); // Clear previous rows var row = $('