Note that there are some explanatory texts on larger screens.

plurals
  1. POon button click - open modal popup with dynamic details
    text
    copied!<p>Have 3 buttons for each size of a product</p> <pre><code>&lt;table width="100%" style="font-family:Calibri, Arial; margin-top:10px"&gt; &lt;?php while($prod_row = mysql_fetch_array($prod_result)) { if($prod_row['name']&lt;&gt;"" &amp;&amp; $prod_row['price']&lt;&gt;0) { ?&gt; &lt;tr&gt; &lt;td style="padding-left:30px"&gt;&lt;?php if($cat == "Design"){echo "Rs. ".$prod_row['price'];}else{echo $prod_row['name']." (Rs. ".$prod_row['price'].")";} ?&gt;&lt;/td&gt; &lt;td style="text-align:center; vertical-align:middle" id="buy_data"&gt;&lt;a role="button" class="btn btn-primary" data-toggle="modal" data-target="&lt;?php if($_SESSION['logged_in']){echo '#buy_product';}else{echo '#login_buy';} ?&gt;" id="&lt;?php echo $prod_row['id']; ?&gt;" name="&lt;?php echo $prod_row['price']; ?&gt;" title="&lt;?php echo $prod_row['name']; ?&gt;"&gt;Buy&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php }//if closes }//while closes ?&gt; &lt;/table&gt; </code></pre> <p>On clicking the link, a modal popup should open showing some details of the clicked size</p> <p>what i am doing is:</p> <ol> <li>triggering an onclick event to store product details (of the clicked size) in session variables via session_product.php</li> <li>displaying the modal with required details using these session variables</li> </ol> <p>script for onclick event</p> <pre><code>$("#buy_data a").unbind("click").click(function(e){ var productnumber = $(this).attr('id'); var prodprice = $(this).attr('name'); var prodsize = $(this).attr('title'); var checkprodid = productnumber; $.post('session_product.php',{productid: checkprodid, productprice: prodprice, productsize: prodsize}); }); </code></pre> <p>session_product.php</p> <pre><code>&lt;?php session_start(); $_SESSION['productprice'] = $_POST['productprice']; $_SESSION['productsize'] = $_POST['productsize'] ?&gt; </code></pre> <p>modal popup</p> <pre><code>&lt;div id="buy_product" class="modal hide fade well" tabindex="-1" role="dialog" aria-labelledby="buy_product_label" aria-hidden="true"&gt; &lt;div class="modal-body"&gt; &lt;h4 id="buy_product_label"&gt;&lt;/h4&gt; &lt;p style='color:#000'&gt; Thank you &lt;b&gt;&lt;?php echo $_SESSION['user_name']; ?&gt;&lt;/b&gt; for showing your interest in our website. You intend to purchase Product ID - &lt;b&gt;&lt;?php echo $_SESSION['prod_code']; ?&gt;&lt;/b&gt;&lt;?php if($_SESSION['cat'] == "Photograph"){ ?&gt; of size &lt;b&gt;&lt;?php echo $_SESSION['productsize'];} ?&gt;&lt;/b&gt; worth Rs. &lt;b&gt;&lt;?php echo $_SESSION['productprice']."-".$_SESSION['cat']; ?&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt; &lt;form id="thanks_popup" action="buy_email_notification.php" method="post"&gt; &lt;input style="text-align:center" class="btn btn-primary" type="submit" id="" name="buy_popup_submit" value="OK, Got it!" /&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Problem: on clicking a link, modal popup is showing product details corresponding to previously clicked link.</p> <p>Please let me know where am i going wrong and what should be the solution to it. thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload