1
I have the following structure, I need to create something "similar" to a shopping cart. When creating a link I need to take the rel of this link and go adding the value of the Hidden input,but I do not want to repeat values, example: If I clicked on Product 1, Product 4 link and clicked on Product 4 again, then I want the value of the Hidden input to receive the values
"product 1,product 4"
the structure of the page is this:
<!DOCTYPE html>
<html>
<head>
<title>Produtos</title>
</head>
<body>
<div class="produtos">
<a href="#" rel="produto1">Produto 1</a>
<a href="#" rel="produto2">Produto 2</a>
<a href="#" rel="produto3">Produto 3</a>
<a href="#" rel="produto4">Produto 4</a>
<a href="#" rel="produto5">Produto 5</a>
<!-- esse input recebe o rel de cada link clicado -->
<form method="post">
<input type="hidden" value="">
</form>
</div>
</body>
</html>
Thanks friend, helped a lot!
– Otavio Fagundes
You’re welcome...
– Sam
Without wanting to abuse your goodwill, but could you please let me know how I would remove the value of the value if I click on a link that already has this result in the array? basically it’s like this: clicou added, clicked removed again. I’m studying JS but haven’t gotten into these more advanced classes yet
– Otavio Fagundes
I moved a change to remove if it already exists.
– richellyitalo
Ah, cool... already done... thanks!
– Sam