I am looking to input data using a specific product ID and save it locally. Upon clicking the button, the data should be stored in the local storage. It is possible for a single product to have multiple filenames associated with it.
For the customer, if they provide the ID, all the filenames linked to that ID should be displayed in a text area.
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<script type="text/javascript">
var filename = []
var productid = []
function managerClick(){
console.log("manager", productid);
console.log("manager", filename);
productid.push(document.getElementById("productId").value);
filename.push(document.getElementById("names").value);
localStorage.setItem("filename", JSON.stringify(filename));
localStorage.setItem("productid", JSON.stringify(productid));
var result={}
productid.map(function(k){
result[k]=filename;
})
console.log(result);
console.log("productid",productid);
console.log("filename",filename);
};
function customerClick(){
console.log("Customer");
document.getElementById('myTextarea').value = filename;
};
</script>
<body>
<div class="w3-card-4 w3-margin" style="width:50%;">
<center>Product Manager</center>
<div class="w3-container">
Product ID: <input type="text" id="productId"><br></br>
File Name: <input type="text" id="names"><br></br>
<center><button class="w3-btn w3-dark-grey" onclick="managerClick()">Enter Data</button></center><br>
</div>
<center>Customer Section</center>
<div class="w3-container">
Product ID: <input type="text" id="CustomerpId"><br></br>
<center>
<button class="w3-btn w3-dark-grey" onclick="customerClick()">Click To Get Filenames</button>
</center><br>
<textarea rows="4" cols="30"></textarea>
</div>
</div>
</body>
</html>
I am looking to assign multiple files to a single product without them being visible to other products. Can someone assist me in achieving this?
I tried implementing the solution mentioned above and encountered issues.
https://i.sstatic.net/j0emN.png
Despite following the instructions, the filenames of product 1 and product 2 are displayed for both products. Ideally, product 1 should have files 1, 2, and 3, while product 2 should have files 1, 2, 3, and 4