How To Pass Multiple Data- Id In A Modal Body
Suppose I have multiple order id $order_id='12345566778'; $prod_id='126778899'; $sell_id='373462562363'; While I select particular orderid I want it to pass in php variable which
Solution 1:
You can use jQuery.data()
method to do this. Try this way:
HTML code
<aclass="open-my-modal"rel="dialog"data-toggle="modal"data-id="<?=$order_id?>"data-prod-id="<?=$prod_id?>"data-sell-id="<?=$sell_id?>"href="#mymodal"data-target="#myModal" ><?phpecho"<br> $order_id </br>";?></a><divclass="modal fade"id="myModal"tabindex="-1"role="dialog"aria-labelledby="myModalLabel"aria-hidden="true"><divclass="modal-dialog"><divclass="modal-content"><divclass="modal-header"><buttontype="button"class="close"data-dismiss="modal"aria-label="Close"><spanaria-hidden="true">×</span></button><tableclass="table table-hover table-bordered" ><trstyle=" background-color:#00AAAD; color:#FFF; "><divclass="modal-body"><divid='order-id'></div><divid='prod-id'></div><divid='sell-id'></div></div></tr></table></div><divclass="modal-footer"><buttontype="button"class="btn btn-default"data-dismiss="modal">
Close
</button></div></div><!-- /.modal-content --></div><!-- /.modal-dialog --></div>
jQuery Code
$(document).ready(function () {
$('.open-my-modal').click(function(){
$('#order-id').html($(this).data('id'));
$('#prod-id').html($(this).data('prod-id'));
$('#sell-id').html($(this).data('sell-id'));
// show Modal
$('#myModal').modal('show');
});
});
Solution 2:
Theres a way you can do this.. The ways is really simple just use variable passing using get or post method. in action tag put the address of the current page.
<formaction='your_current_page'method='post'><selectname='id'id='order_id'><optionvalue='12345566778'>12345566778</option><optionvalue='126778899'>126778899</option><optionvalue='373462562363'>373462562363</option></select><?php$order_id=$_POST['id']; # id is you name attribute in select tag?>
this is how you going to pass variables from html to php... hope this solves the problem..
Post a Comment for "How To Pass Multiple Data- Id In A Modal Body"