I have written a function to "highlight" the "product-box" that is clicked by adding a red border around it. However, I want users to be able to select up to 3 boxes at once. As of now, my function adds the border to one and does nothing after.
<div class="col-md-9"><!-- col-md-9 Begin (Category Listed on Top) -->
<?php
getpcatpro();
$get_products = "select * from products order by rand() LIMIT 0,9";
$run_products = mysqli_query($con,$get_products);
while($row_products=mysqli_fetch_array($run_products)){
$pro_id = $row_products['product_id'];
$pro_title = $row_products['product_title'];
$pro_img1 = $row_products['product_img1'];
$pro_link = $row_products['product_link'];
echo "
<div class='col-md-4 col-sm-6'>
<div class='product' id='product-box' onclick='highlight();'>
<center>
<img class='img-responsive' src='admin_area/product_images/$pro_img1' style='margin-top: 5%;'>
</center>
<div class='text'>
<center>
<a href='$pro_link' style='color: black;'> $pro_title </a>
</center>
</div>
</div>
</div> ";
}
?>
<script> <!-- Script to add border around journal box on click -->
function highlight(){
document.getElementById('product-box').style.border = "1px solid red";
}
</script>
</div>
getElementById('product-box')I'm assuming that you're duplicating them which, as you saw, won't work.id='product-box-$pro_id'