PASS VARIABLE FROM HTML PAGE TO TABCONTENTS PAGE

HOW CAN I PASS THE PRODUCT ID FROM PRODUCT VIEW PAGE TO NEW PAGE WHICH IS OPEN BY ONCLICK EVENT

  • Ishwar
  • 30 Apr 2026
  • 2357 Views
  • 9 Answers
Your Answer

my project is as given kindly help me on that
product.php code as follows
 <?php
  include('../dbcon.php');
  $sql="SELECT `Id`, `Short`, `Rate`, `Long_description`, `Restaurant`, `Image` FROM `menu` order by Id ASC";
  
  $run=mysqli_query($con,$sql);
  $num=mysqli_num_rows($run);
  
  
  if($num>0){
  while($product=mysqli_fetch_assoc($run)){
?>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
<form method ="POST" action="../assets/shopcart.php" >
<div id="cards">
<h5 class="card-title bg-info text-white p-2 text-uppercase"><?php echo $product['Short'];?></h5>
<div class="card-body">
<img src="../image/<?php echo $product['Image']; ?>"alt ="" class="img-responsive mx-auto">
<input class="text-uppercase" type="text" style="text-align:center; width:100%; border-radius:5px; font-size:20px;" name="rest" value="<?php echo $product['Id'];?>" ></input>
<h5>&#8377;<?php echo $product['Rate'];?> ( <span><?php echo $product['Rate'];?> %off )</span></h5>
<h5><?php echo $product['Restaurant'];?></h5>
<!-- <input type ="number" name="getid" value=<?php echo $product['Id'];?></input>-->
</div>
<div class="btn-group d-flex">
<!--<button class="btn btn-success flex-fill"> add to cart</button>
<button class="btn btn-warning flex-fill"> buy now</button>-->
<a href="../assets/shopcart.php?sid=<?php echo $product['Id'];?>" style="font-size:20px;" name="cartg" class="btn btn-primary" onclick="openNav3()">&#9776; VIEW</a>
<a href="#" style="font-size:20px;" name="tst" class="btn btn-primary" onclick="openNav3()">121</a>
</div>
</div>
</form>
</div>
<?php
}
} 
  ?>


by conclick function as followes


<script>



function openNav3() {
  document.getElementById("mySidenav3").style.width = "364px";
  document.getElementById("main").style.marginLeft = "250px";
  
function closeNav3() {
  document.getElementById("mySidenav3").style.width = "0";
  document.getElementById("main").style.marginLeft= "0";
  }
</script>

  <div id="mySidenav3" class="sidenav2">

  <a href="void(0)" class="closebtn" onclick="closeNav3()">&times;</a>
<div class="pay">

<div class="demo">
<h4> ADD TO CARD <span class="fa fa-shopping-cart"</span></h4>

Javascript

Didn't get the answer.
Contact people of Talent-Javascript directly by clicking here